<script language="JavaScript">
function test()
{
if((form1.START.value+0)>(form1.END.value+0))
{
....;
}
return;
}
</script>或者 parseInt()
function test()
{
if((form1.START.value+0)>(form1.END.value+0))
{
....;
}
return;
}
</script>或者 parseInt()
是parseInt(form1.START.value)吗?谢谢
document.write("<BR>" + parseInt("50"))
document.write("<BR>" + parseInt("50.12345"))
document.write("<BR>" + parseInt("32.00000000"))
document.write("<BR>" + parseInt("71.348 92.218 95.405"))
document.write("<BR>" + parseInt(" 37 aardvarks"))
document.write("<BR>" + parseInt("Awarded the best wine of 1992"))
Output:
50
50
32
71
37
NaN
Code:
document.write(parseInt("110", 2))
Output:
6
You can use the optional radix argument to convert a hexidecimal number string to the decimal (base 10) equivalent.
Code:
document.write(parseInt("0xD9", 16))
Output:
217
You can use the isNaN function to see if the returned value is a NaN.
Code:
pet = "Rachel has 312 baby aardvarks"
CheckNum = parseInt(pet)
if(isNaN(CheckNum))
{
document.write("<BR>Sorry, CheckNum is a NaN")
document.write("<BR>Left-most character = " + pet.substring(0,1))
}
Output:
Sorry, CheckNum is a NaN
Left-most character = R
function test()
{
if(parsInt(form1.START.value)>parsInt(form1.END.value))
{
....;
}
return;
}
</script>
<script language="JavaScript">
function test()
{
form1.ABC.value=form1.START.value+form1.END.value;
return;
}
</script>