So it all started out with me at my computer working on some JS when i decided to add a clear button to get rid of info in text boxes. so i put a button on my page (value="Clear!") and wrote the code, onclick"clear();".
<input type="button" value="Clear!" onclick="clear()">
Then i created a function that looked like this:
function clear() {
document.averages.abox.value="Average Here!"
document.averages.numberbox1.value=""
document.averages.numberbox2.value=""
document.averages.numberbox3.value=""
}
But it did not work when i tried it.
So, suspicious that i had used clear before, i checked for clear, but it wasnt any where on my page but those to places, so i tried changing the name to "clearem()" and changed them in both places. And it worked. I assumed that clear must be a restricted word, but it wasnt.
Does anyone have an answer to this akwardity of JS?
Javascript being akward
Moderator:Moderators
Falco upon hearing that Slippy and his fiancee are stranded on the water planet:
"What? Slippy's engaged? Like, to a woman?"
"What? Slippy's engaged? Like, to a woman?"
Re: Javascript being akward
thats java for ya. java<c_(insert + or ++ or leave it blank)
AfroLH wrote:Yeah well Alcohol adds a little bit of sexyness in my eyes, but I dont drink it all the time.HotDog-Cart wrote: Also, the codename stuff adds a little bit of sexyness, in my eyes.
SpongeBuell wrote:As proof, I offer this picture of a monkey on my head.
Re: Javascript being akward
Javascript isn't awkward at all. It's just too lenient in some browsers:
the problem is that each line of javascript is supposed to end with a semicolon (;)
sometimes when you forget to end with ; browsers are able to figure out what you meant and the script seems to work.
This is very annoying when testing across all browsers, so just go down your code and check the ends of lines for semicolons.
the problem is that each line of javascript is supposed to end with a semicolon (;)
sometimes when you forget to end with ; browsers are able to figure out what you meant and the script seems to work.
This is very annoying when testing across all browsers, so just go down your code and check the ends of lines for semicolons.