rjsaul0
IS-IT--Management
- Mar 2, 2006
- 6
Hi,
In the example below, the reference to document.form1.vcol.value works in the pick function but error says not defined in the crand function. Using IE 7.
Rick
<html>
<Script type="text/javascript">
<!--
function crand () {
var rnum = Math.random();
var rc;
if (rnum < 0.5)
{rc = "red";}
else
{rc = "blue";}
document.form1.vcol.value=rc;
return rc;
}
function pick(c) {
document.form1.result.value=c;
document.form1.vcol.value=c;
// window.alert(c);
return;
}
var rcol = crand();
// hide -->
</Script>
<Style type='text/css'>
<!--
#ButtonR{
background-color:red;
color:black;
font-size:medium
}
#ButtonB{
background-color:blue;
color:black;
font-size:medium
}
-->
</Style>
<body>
<h2>Guess color, red or blue</h2>
<form name=form1>
<input id='ButtonR' type="button" name=button1 value="Click" onClick="pick('red',rcol)">
<input id='ButtonB' type="button" name=button2 value="Click" onClick="pick('blue',rcol)">
<input type="text" name=vcol size=5>
<input type="text" name=result size=4>
<br>
<input type="RESET" value="Reset" onClick="rcol = crand()">
</form>
</body>
</html>
In the example below, the reference to document.form1.vcol.value works in the pick function but error says not defined in the crand function. Using IE 7.
Rick
<html>
<Script type="text/javascript">
<!--
function crand () {
var rnum = Math.random();
var rc;
if (rnum < 0.5)
{rc = "red";}
else
{rc = "blue";}
document.form1.vcol.value=rc;
return rc;
}
function pick(c) {
document.form1.result.value=c;
document.form1.vcol.value=c;
// window.alert(c);
return;
}
var rcol = crand();
// hide -->
</Script>
<Style type='text/css'>
<!--
#ButtonR{
background-color:red;
color:black;
font-size:medium
}
#ButtonB{
background-color:blue;
color:black;
font-size:medium
}
-->
</Style>
<body>
<h2>Guess color, red or blue</h2>
<form name=form1>
<input id='ButtonR' type="button" name=button1 value="Click" onClick="pick('red',rcol)">
<input id='ButtonB' type="button" name=button2 value="Click" onClick="pick('blue',rcol)">
<input type="text" name=vcol size=5>
<input type="text" name=result size=4>
<br>
<input type="RESET" value="Reset" onClick="rcol = crand()">
</form>
</body>
</html>