crazyman
02-19-2008, 03:54 AM
Somebody please tell me why my code don't work, when i reference agrument by function ,it dislay my text box not a object??where is my misstake?thank you very much.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script>
function check(num)
{
if(num=="")
{
alert(" please enter a number")
}
if(isNaN(num) )
{
alert("please enter a number value")
}
}
function calMath(form)
{
with(form)
{
document.myform.rt.value= eval(box1.value + ra1.value + box2.value)
}
}
</script>
</head>
<body>
<form name="myform">
<table>
<tr>
<td>Number 1:</td><td> <input name="box1" onblur="check(this.value)"/></td>
<tr ><td colspan="2" align="center"><input type="radio" name="ra1" value="+" />+
<input type="radio" name="ra1" value="-" />-
<input type="radio" name="ra1" value="*" />*
<input type="radio" name="ra1" value="/" />/</td>
<tr>
<td>Number 2:</td><td> <input name="box2" onblur="check(this.value)" /></td>
<tr><td><input type="button" value="Result" onclick="calMath(this.form)" /></td><td> <input name="rt" type="text" /></td>
</table>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script>
function check(num)
{
if(num=="")
{
alert(" please enter a number")
}
if(isNaN(num) )
{
alert("please enter a number value")
}
}
function calMath(form)
{
with(form)
{
document.myform.rt.value= eval(box1.value + ra1.value + box2.value)
}
}
</script>
</head>
<body>
<form name="myform">
<table>
<tr>
<td>Number 1:</td><td> <input name="box1" onblur="check(this.value)"/></td>
<tr ><td colspan="2" align="center"><input type="radio" name="ra1" value="+" />+
<input type="radio" name="ra1" value="-" />-
<input type="radio" name="ra1" value="*" />*
<input type="radio" name="ra1" value="/" />/</td>
<tr>
<td>Number 2:</td><td> <input name="box2" onblur="check(this.value)" /></td>
<tr><td><input type="button" value="Result" onclick="calMath(this.form)" /></td><td> <input name="rt" type="text" /></td>
</table>
</form>
</body>
</html>