Page 1 of 1

Javascript issue.

Posted: Sun Sep 04, 2005 10:33 am
by pilau
Hi.
I am working on different measuring units calculator.
I am using a form to work this whole up.
The emtire calculation is done with JavaScript.
Today I worked ona routine that would disable the submit button if a user enetered zero: (I used the onKeyPress event inside the textfield where users enter the number. )
You just dont need to convert zero miles to zery knots, for example.

Code: Select all

function makeGrey() {
   cValue = document.convert.InUnit.value / 1;
//Divding by 1 is incase someone input 00 or 000 and so on
  if (cValue != 0) {
    document.convert.submitButton.disabled=false;
  }

  else {
  	document.convert.submitButton.disabled=true;
  }
}
The problem is this case, that even if I enter the number "3" for example, or anyother numer if you like, it disables the submit buton. Why?

Posted: Sun Sep 04, 2005 11:19 am
by Burrito
Moved to Client Side

Posted: Sun Sep 04, 2005 11:27 am
by pilau
Oh shoot, JS is client-side forum, sorry.
Maybe now people will help me.
People help me!

Posted: Sun Sep 04, 2005 12:21 pm
by feyd
maybe you're getting an undefined property ?

Posted: Sun Sep 04, 2005 1:28 pm
by pilau
No, I don't get any JS errors, the script works just fine, except it's not doing what it's supposed to do, which is disable the submit button when there's 0 in the entry textfield.

Posted: Sun Sep 04, 2005 1:51 pm
by feyd
live example somewhere?

Posted: Sun Sep 04, 2005 1:55 pm
by pilau
Yeah, sorry, I'll upload it to my webserver..
Here: http://www.wormiverse.com/rewclan/sducv4.html