JavaScript - Clarification
hey
i was just wondering, if i need the user to input a sentence then the program would flip every word in the sentence, do i use an array? or do i just use a string? thank you Similar Tutorialsif i have: function someFunction(){ var original = "Original Variable"; anotherFunction(original); } function anotherFuntion(){ /* 1.does the original variable automatically get passed? 2. will var transformed = original + "Transformed" give me a result of "Original Variable Transformed"? 3. Or does it have to be declared in the function: anotherFunction(original) */ } thanks for any help Hi: Not sure if the title of this post makes sense, so hear is my question. I am reading about DOM and how to write JS with it, and was able to put together a simple script as an exercise to teach myself: Code: <html> <head> <script> function formIt() { document.getElementById("mySearchBox").value = ""; document.getElementById("mySearchBox").style.color="#f00"; } </script> </head> <body> <form name="myForm" id="myForm"> <input type="text" id="mySearchBox" name="mySearchBox" onfocus="javascript:formIt()" value="Search" /> </form> </body> </html> And am realizing that I can use other styles and write a function to set the form back to it's original state: Code: <html> <head> <script> function formIt() { document.getElementById("mySearchBox").value = ""; document.getElementById("mySearchBox").style.color="#ff0"; document.getElementById("mySearchBox").style.background="#f0f"; document.getElementById("myForm").style.background="#fdf"; document.getElementById("myForm").style.height="200px"; document.getElementById("myForm").style.width="25%"; } function unFormIt() { document.getElementById("mySearchBox").value = "Search"; document.getElementById("mySearchBox").style.color="#000"; document.getElementById("mySearchBox").style.background="#fff"; document.getElementById("myForm").style.background=""; } </script> </head> <body> <form name="myForm" id="myForm"> <input type="text" id="mySearchBox" name="mySearchBox" onfocus="javascript:formIt()" onblur="javascript:unFormIt()" value="Search" /> </form> </body> </html> It's all very basic but how to use "getElemetByID" and the basics of using the DOM are clicking. So, I am wondering if the "style" portion of the code is equivalent to a CSS style tag, like: Code: #formIt { color: #f00; background: #f0f; height: 200px; width: 30%; } It seems like it is. And if that is correct, how would I control the font size, family, etc this way? Whenever I try to do something like: Code: document.getElementById("mySearchBox").style.font-size="18pt"; The script fails, I'm assuming because of the hyphen ?? Anyone clarify all of this for me? Thanks! |