Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-08-2003, 03:38 AM   PM User | #1
admin11
New to the CF scene

 
Join Date: Jul 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
admin11 is an unknown quantity at this point
JavaScript If Statements

I'm having trouble with my If Statements not working. The syntax is correct according to many sources. Do you think it could be the browser? Maybe there is a patch for this. Please respond if you have had similar problems. Thank you for any suggestions.
admin11 is offline   Reply With Quote
Old 07-08-2003, 03:54 AM   PM User | #2
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
show us some code?
__________________
"Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark
brothercake is offline   Reply With Quote
Old 07-08-2003, 05:00 AM   PM User | #3
admin11
New to the CF scene

 
Join Date: Jul 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
admin11 is an unknown quantity at this point
Here is an example of one of my If statements that does not work. If I type a value other than 0, 1, or 2 the alert should pop up, but it doesn't. Any suggestions?

function APGAR() {
if(field.value==0 || field.value==1 || field.value==2) {
var A=eval(document.REG.ACT.value);
var P=eval(document.REG.PULSE.value);
var G=eval(document.REG.GRIMACE.value);
var AP=eval(document.REG.APP.value);
var R=eval(document.REG.RESP.value);
document.REG.TOTAL.value=A+P+G+AP+R;
} else {
alert("You must enter a 0, 1, or 2");
field.focus();
}
}
admin11 is offline   Reply With Quote
Old 07-08-2003, 08:44 AM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
hm...shouldn't be here somewere something like var somevalue= newString(); ? I think that math values and string characters are not the same thing...
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 07-08-2003, 09:45 AM   PM User | #5
ellisd5
Regular Coder

 
ellisd5's Avatar
 
Join Date: Jun 2002
Location: Uk
Posts: 160
Thanks: 5
Thanked 0 Times in 0 Posts
ellisd5 is an unknown quantity at this point
Think Kor's got it there, forms return strings so you need to turn it into number format so your code will now be

Code:
    var theVal = parseInt(field.value, 10);
    if (theVal >= 0 && theval <= 3) {
ellisd5 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:36 AM.


Advertisement
Log in to turn off these ads.