* Login 
* FAQ    * Search

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Javascript being akward
PostPosted: Fri May 08, 2009 11:02 am 
Offline
User avatar

Joined: Fri Mar 06, 2009 3:59 pm
Posts: 15
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?

_________________
Falco upon hearing that Slippy and his fiancee are stranded on the water planet:

"What? Slippy's engaged? Like, to a woman?"


Top
 Profile E-mail  
 
 Post subject: Re: Javascript being akward
PostPosted: Mon May 11, 2009 9:28 pm 
Offline
User avatar

Joined: Sun Feb 15, 2009 8:05 pm
Posts: 1086
Location: burning and pillaging!!
thats java for ya. java<c_(insert + or ++ or leave it blank) :P

_________________
AfroLH wrote:
HotDog-Cart wrote:
Also, the codename stuff adds a little bit of sexyness, in my eyes.


Yeah well Alcohol adds a little bit of sexyness in my eyes, but I dont drink it all the time. :wink:

SpongeBuell wrote:
As proof, I offer this picture of a monkey on my head.


Top
 Profile E-mail  
 
 Post subject: Re: Javascript being akward
PostPosted: Sun Sep 06, 2009 10:09 am 
Offline

Joined: Sun Sep 06, 2009 10:04 am
Posts: 6
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.


Top
 Profile E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group