Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Problem with browser maybe?
Old 06-22-2005, 10:18 PM Problem with browser maybe?
waller's Avatar
Skilled Talker

Posts: 59
Location: North Borneo.
Trades: 0
PHP Code:
<html>

<
head>
<
script type="text/javascript">
function 
formSubmit()
{
x=document.forms.myForm
fname
=x.firstname.value.replace(/:/g,"")
lname=x.lastname.value.replace(/:/g,"")

var 
num1=parseInt(fname)
var 
num2=parseInt(lname)

if (
fname<lname){
alert (lname)
false
}
else if (
fname>lname){
alert (fname)
false
}
else{
alert (num1 num2)
}

}
</script>
</head>

<body>
<form name="myForm" action="js_form_action.asp" method="get">
Firstname: <select name="firstname" size="1"> <option>00:00:00</option> <option>00:30:00</option>
 <option>01:00</option>  <option>01:30</option>
 <option>02:00</option></select>
<br />
                            
Lastname: <select name="lastname" size="1">
<option>00:00:00</option> <option>00:30:00</option>
 <option>01:00</option>  <option>01:30</option>
 <option>02:00</option></select>
<br /><br />
<input type="button" onclick="formSubmit()" value="Submit">
</form>
</body>

</html> 
I have this code above. You may try to run it as htm or html.
My problem is, when i open it in my browser in my office (Mozilla Firefox) with Win 2000 OS, its doing fine. But if I run it at home (IE6) with WinXP OS, all it display in the alert box is "NaN".
My question is, what is NaN, and does it have something to do with my browser and how can I fix this. Thankas very much.
__________________
$id ="waxxer";
$id = str_replace('x', 'l', $id);
echo $id;
echo " and Marj";
waller is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-27-2005, 05:47 PM
kline11's Avatar
SearchBliss Web Tools

Posts: 1,726
Name: John
Location: USA
Trades: 0
NaN in javascript standes for "Not a Number." In your code you have
var num1=parseInt(fname)
var num2=parseInt(lname)
"parseInt" returns a number up until the end of the number or to a decimal point. "fname" and "lname" are not numbers. "123fname" will return "123", but "fname123" will return "NaN". This tells me that there is a problem with defining "fname" and "lname" in this section:
fname=x.firstname.value.replace(/:/g,"")
lname=x.lastname.value.replace(/:/g,"")

Try changing this:
x=document.forms.myForm
fname=x.firstname.value.replace(/:/g,"")
lname=x.lastname.value.replace(/:/g,"")

To this:
x=this.form
fname=x.firstname.options[x.firstname.selectedIndex].value.replace(/:/g,"")
fname=x.lastname.options[x.lastname.selectedIndex].value.replace(/:/g,"")
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Last edited by kline11; 06-27-2005 at 05:49 PM.. Reason: typo
kline11 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Problem with browser maybe?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.46477 seconds with 12 queries