Jump to content

DocGrimwig

Members
  • Posts

    21
  • Joined

  • Last visited

Everything posted by DocGrimwig

  1. dsonesuk...What an incredible gift you have given me. Thank you. I know that all of your Moderating takes up a great deal of time an effort, and so I want to say how appreciative I am of the time spent educating me. This was undoubtedly the best teaching on the web! I'm glad to say...I"VE GOT IT!!! -Doc
  2. Wow. This is so readable and helps me immensely to understand the flow. Thanks, Dave. dsonesuk, I'm not saying yours isn't, but I am saying that I am so new to this stuff, that your explanation goes right over the top of my head. I'm just barely above the level of "See Spot run. Run Spot run " (A children's book in case you're not from a country or a time when this book was in use teaching children to read :-) Dave and ds, for the sake of my education, is there not a simpler way than having to break the script down into 3 functions? For example, is it possible to include init and run within createString? Thanks so much both of you!!!! Doc
  3. So once I have targetted the userInput.value, how do I get it into the parameters for createString if not through a var like n?
  4. Oops. I didn't finish my thought... Instead of hard-coding an input and outputting to the console, I am trying to pass the value of an input to the function and then output it using .innerHTML.
  5. Hello: Below I successfully created a random string generator in js. As you can see, to verify it worked,I logged the output to the console. Now I have tried for hours to do something I thought was incredibly easy, and it probably would be if it weren't I trying to author it :-0 Commented out is the latest of my attempts to do so. The live code works correctly. <!doctype html><html><head><meta charset="utf-8"><title>Random String</title></head><body><!-- <h3>Please input a number to represent how long of a string you wish to randomly create</h3><input name= "userInput" id="userInput" maxlength="2"><button type="submit" onClick="createString()">Submit</button> <p id="output"></p>--><script>//Create function that will produce a random string from a supplied set of characters.function createString(n) { //Declare String Variable.var text = "";// n = [];//List of characters to be drawn fromvar char_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; //Loopfor(var i=0; i < n; i++ ) { text += char_list.charAt(Math.floor(Math.random() * char_list.length)); } //Return the value of the function to the var "test"return text; } //Display the value of the returned random string to the console. Call the function with a parameter n of 10console.log(createString(10)); //document.getElementById("output").innerHTML= createString();</script></body></html> Can you help! Thanks so much, Doc
  6. In the following code: <codeblock> <script> $(document).ready(function(){ $("#hide").click(function(){ $("img").hide(); }); $("#show").click(function(){ $("img").show(); }); }); </script> </codeblock> Is my method and syntax correct for hiding an <img>? Thanks, Doc
  7. justsomeguy: Unfortunately when I click the button it does nothing. There are no syntax errors so I don;t know what it is. It looks right... Doc
  8. So here is my program to take a user input, process it for all possible word combinations and then output the resulting string array to a p string I have been working on this for weeks and was sure I had finally gotten it. Can anyone help? Thanks! Doc <codeblock> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Word Combinations</title> </head> <body> <h3>Please input a word to be processed for all of its possible combinations:</h3> <input id="userInput" type="text" autofocus="autofocus"> <button id="processInput" onClick="getAnagrams("userInput")">Process</button> <p id="returnValue"></p> <script> function swap(chars, i, j) { var tmp = chars; chars = chars[j]; chars[j] = tmp; } function getAnagrams(input) { //initialize the variables var counter = [], anagrams = [], chars = input.split(''), length = chars.length, i; //determine how many letters are in the string for (i = 0; i < length; i++) { counter = 0; } // for loop 1st it will set i to 0; then if i < 3 (using Dog); increment by 1's //next loop sets i to 1; i is still less than 3; so increment by 1 again //next loop sets i to 2; i is still less than 3; so increment by one again //next loop sets i to 3; i is NO LONGER less than 3 so loop stops and returns a string length of 3 (0,1,2 = 3 in the array) //push the original string in container anagrams.push(input); //the (input) string 'dog' is put into the anagrams container //start from first letter i = 0; while (i < length) { if (counter < i) { // i is now = to 0 in the array = 'd' // WHILE i < 3 and IF the loop counter is less than 3 then perform the following //swap the two letters in questions swap(chars, i % 2 === 1 ? counter : 0, i); //increment counter counter++; i = 0; //push new combination into container anagrams.push(chars.join('')); } else { counter = 0; //increment counter i++; } } //return string of results // return anagrams; //Place the result of anagrams into the p id = "returnValue" document.getElementById("returnValue").innerHTML = anagrams; } </script> </body> </html> </codeblock>
  9. Thanks. It is such a big mtn to climb. Thanks for your help. Any opinion on should I learn something like Angular.js to bootstrap etc? And if so, before I do .js or after?
  10. I understood permutations to mean: d, o, g, do, od, dg, gd.....dog, dgo, odg ect... So what is the above??
  11. I'm so new to this. I'm an idiot "justsomeguy." I don;t need recursion after all, I am thinking incorrectly. I just need to get it accomplished. I feel stupid.
  12. I have been trying to apply the theory of recursion to practical application within a JS function. At first I thought it would be easy. I have found several attempts, but most are all over the place and it's hard to follow them and to learn something from them. I have spent days with others, only to discover they are not using proper JS protocols. Can anyone link me to a GREAT Word Combination (recursive, repeating) -permutations, JS function that finds all of the combinations of an input word and displays them in the browser? I am so new that I can't tell what's good or what's bad. Thanks! Doc
  13. I am totally new to programming and am trying to adapt a snippet that was written to the console so that it now takes a user input and outputs to the browser. I have searched w3schools and other helps, but can't seem to get this last bit done. I don;t have any syntax issues apparently, and haven't earned to debug yet, so I've hit a wall. Can you help? <codebox> <!doctype html> <html> <head> <meta charset="utf-8"> <title>Possible Word Combinations</title> </head> <body> <h4>Please input a word below</h4> <input type="text" id="userInput" > <button onclick="scramble()">Submit</button> <p id="inputValue"></p> <script> function scramble(word) { var word = document.getElementById("UserInput") var words = [], rearrangedWord, head, tail; if (!word) { return words; } function rearrange(str, prefix) { prefix = prefix || ''; str.split('').map(function(head, idx) { tail = str.slice(0, idx) + str.slice(idx + 1); rearrangedWord = prefix + head + tail; if (words.indexOf(rearrangedWord) < 0) { words.push(rearrangedWord); } if (tail.length > 1) { rearrange(tail, prefix + head); } }); } rearrange(word, ''); return words; } document.getElementById("inputValue").innerHTML = words; (scramble("userInput")); </script> </body> </html> </codebox>
  14. Ok, so this is too much! Thank you!!!!!!!!!!!! Do you like Starbucks or something else?
  15. I am new to js and am trying to learn something via the following snippet: <code> function substrings(str1) { var array1 = []; for (var x = 0, y=1; x < str1.length; x++,y++) { array1[x]=str1.substring(x, y); } var combi = []; var temp= ""; var slent = Math.pow(2, array1.length); for (var i = 0; i < slent ; i++) { temp= ""; for (var j=0;j<array1.length;j++) { if ((i & Math.pow(2,j))){ temp += array1[j]; } } if (temp !== "") { combi.push(temp); } } document.write.log(combi.join("n")); } substrings("dog"); </code> (1) how can I change the output to go to my browser instead of the console and (2) can someone please answer a stupid question like what is the benefit of writing to the console. As I said I am totally new and don't have handle on the uses of the console yet. I know its for debugging, i think... :-)
  16. Thanks again for your reply. Your help is invaluable. Do you know if there are copyright laws specifically directed toward web based applications?
  17. I am a complete Newbie and will be embarking on a big project to use a device for learning the web dev languages. That being said, with the availability of page source code info, inspect element etc. What should I be studying at the outset so that my design can't merely be cut and pasted and sold after all my hard work. I know there are copyrights laws, but we all no they are only a good as the paper they were written on if a person is determined to pirate something.
  18. I have been toying with web development for 10+years using tools like MUSE to make it easier. That has become so unsatisfying. So I am wanting to learn both client-side and server-side languages by creating a large robust database driven application that runs completely in the cloud. This app will be somewhat like a service desk app in that it will take in much data and based upon each user input, will cause a multitude of actions such as: contacting by email a person to handle the case, open a case file and place it within one of several appropriate scenarios in order to properly bring the case to resolve. Each of these scenarios will have its own ("to-do) list, case management and personnel notification. From this limited information, are you able to render a conclusion as to whether or not I can do this all in the web, or will I have to learn another programming language (ie. C+, C#) that will have to be compiled and executed on the clients local device? Thanks for your help! Doc
×
×
  • Create New...