Javascript issue.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Javascript issue.

Post 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?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Moved to Client Side
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

Oh shoot, JS is client-side forum, sorry.
Maybe now people will help me.
People help me!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

maybe you're getting an undefined property ?
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

live example somewhere?
pilau
Forum Regular
Posts: 594
Joined: Sat Jul 09, 2005 10:22 am
Location: Israel

Post by pilau »

Yeah, sorry, I'll upload it to my webserver..
Here: http://www.wormiverse.com/rewclan/sducv4.html
Post Reply