Palomares
09-24-2005, 08:20 PM
Lets see, here's my code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript" >
var flag ;
var Digito ;
var Operador
function EscribeDigito(Digito)
{
window.document.form1.raultext.value=(Digito)
var flag = true;
return false;
}
function valTest()
{
window.alert("The value of flag is "+ flag);
window.alert("The value of digito is "+ Digito);
}
//function Operator(Digito,Operador)
//{ if (flag == true)
// {
// window.document.form1.raultext.value=(Digito+Operador);
// }
</script>
</head>
<body>
<form name="form1" method="post" action="">
<p>
<input type="text" name="raultext">
</p>
<p>
<input name="button1" type="submit" id="button1" value="1" onClick="EscribeDigito(1); return false;" >
<input name="valueTest" type="submit" id="valueTest" value="valueTest" onClick="valTest();">
<input name="multiply" type="submit" id="multiply" value="*" onClick=" Operator(Digito,*); return false;">
</p>
<p>
<input name="button2" type="submit" id="button2" value="2" onClick="EscribeDigito(2); return false;" >
</p>
<p>
<input name="button3" type="submit" id="button3" value="3" onClick="EscribeDigito(3); return false;" >
</p>
</form>
</body>
</html>
The reason for the valTest function is that after running the Escribedigito function,by running the Onclick function, I am testing whether the flag and Digito values change.
I'd like to make them change to flag = true and Digito = (To whatever button you onclick).
I know here's a Global and Local variable issue, but is there a way I could modify the value of a global variable from a function??
(I hope you understand what I mean as I suppose it's not difficult to tell that, yes I am a Newbie!)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script type="text/javascript" >
var flag ;
var Digito ;
var Operador
function EscribeDigito(Digito)
{
window.document.form1.raultext.value=(Digito)
var flag = true;
return false;
}
function valTest()
{
window.alert("The value of flag is "+ flag);
window.alert("The value of digito is "+ Digito);
}
//function Operator(Digito,Operador)
//{ if (flag == true)
// {
// window.document.form1.raultext.value=(Digito+Operador);
// }
</script>
</head>
<body>
<form name="form1" method="post" action="">
<p>
<input type="text" name="raultext">
</p>
<p>
<input name="button1" type="submit" id="button1" value="1" onClick="EscribeDigito(1); return false;" >
<input name="valueTest" type="submit" id="valueTest" value="valueTest" onClick="valTest();">
<input name="multiply" type="submit" id="multiply" value="*" onClick=" Operator(Digito,*); return false;">
</p>
<p>
<input name="button2" type="submit" id="button2" value="2" onClick="EscribeDigito(2); return false;" >
</p>
<p>
<input name="button3" type="submit" id="button3" value="3" onClick="EscribeDigito(3); return false;" >
</p>
</form>
</body>
</html>
The reason for the valTest function is that after running the Escribedigito function,by running the Onclick function, I am testing whether the flag and Digito values change.
I'd like to make them change to flag = true and Digito = (To whatever button you onclick).
I know here's a Global and Local variable issue, but is there a way I could modify the value of a global variable from a function??
(I hope you understand what I mean as I suppose it's not difficult to tell that, yes I am a Newbie!)