trewyn15
New Member
Hey guys, writing a code for class, I think I have it probably 95% done, just need a little help finishing it up.
Here's what supposed to be done:
Here's what I currently have:
As you can probably tell, I'm not getting the correct display. I think my problem is that my Variables are not stated correctly in the beginning, but I'm not 100% sure. Any help would be greatly appreciated!
Here's what supposed to be done:
Here's what I currently have:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script language="JavaScript">
function echo()
{
document.write
var int = parseInt(document.inform.instr.value);
var real = parseReal(document.inform.instr.value);
var str = (document.inform.instr.value);
if
{
(0 <= int && int <=99 &&
(0.0 <= real && real <= 10.0) &&
(str != null))
document.write(<h1>"All input is valid:"</h1>);
("Int No. = " + document.getElementsByName("int")[0].value + "<br>" +
"Real No. = " + document.getElementsByName("real")[0].value + "<br />" +
"String Length = " + document.getElementsByName("string")[0].length );
return true;
}
else
{
window.alert("Form error, please try again!");
return false;
}
}
</script>
</head>
<body>
<form name="inform" onsubmit="echo()" id="myform">
Enter Int No: <input type="text" name="int" id="myinput" /> (0-99)<br />
Enter Real No: <input type="text" name="real" /> (0.0-10.0)<br />
Enter String: <input type="text" name="string" /><br />
<input type="submit" /><br />
</form>
</body>
</html>
As you can probably tell, I'm not getting the correct display. I think my problem is that my Variables are not stated correctly in the beginning, but I'm not 100% sure. Any help would be greatly appreciated!