Hi guys,
Can anyone tell me how to place two fuctions on one onClick event. They both work fine seperately, but not together.
The code is below: (note - the code for the second function is beneath the </HTML> tag)
<HTML>
<HEAD>
<SCRIPT language=JavaScript>
function UseIt()
{
var qty = document.lotto1.ammount.value
var ship = 30
var num1 = Math.round(550 * qty)
var num2 = Math.round(num1 + ship * qty)
document.lotto1.sub1.value=num1
document.lotto1.box7.value=num2
}
</SCRIPT>
<SCRIPT type="text/javascript" >
function fdp(n, d)
{ d = (d>10?10:d);
d = (d<0?0:d);
var r = "" + Math.round(n * Math.pow(10,d));
return (d==0?r:r.substring(0,r.length-d)+"."
+r.substring(r.length-d,r.length));
}
</SCRIPT>
</HEAD>
<BODY bgColor=#ffffff>
<H3>Place a number in Qty box:</H3>
<form name="lotto1">
Qty<input type="text" name="ammount">sub total<input type="text" name="sub1">
<br>
$<input type="text" name="ship" value="30" readonly>
<br>
<INPUT name=box7>
<p>
<input type="button" value="Click to see results" onClick="UseIt()">
</FORM>
</BODY>
</HTML>
"lotto1.box7.value =
fdp(lotto1.ammount.value, 2)"
Can anyone tell me how to place two fuctions on one onClick event. They both work fine seperately, but not together.
The code is below: (note - the code for the second function is beneath the </HTML> tag)
<HTML>
<HEAD>
<SCRIPT language=JavaScript>
function UseIt()
{
var qty = document.lotto1.ammount.value
var ship = 30
var num1 = Math.round(550 * qty)
var num2 = Math.round(num1 + ship * qty)
document.lotto1.sub1.value=num1
document.lotto1.box7.value=num2
}
</SCRIPT>
<SCRIPT type="text/javascript" >
function fdp(n, d)
{ d = (d>10?10:d);
d = (d<0?0:d);
var r = "" + Math.round(n * Math.pow(10,d));
return (d==0?r:r.substring(0,r.length-d)+"."
+r.substring(r.length-d,r.length));
}
</SCRIPT>
</HEAD>
<BODY bgColor=#ffffff>
<H3>Place a number in Qty box:</H3>
<form name="lotto1">
Qty<input type="text" name="ammount">sub total<input type="text" name="sub1">
<br>
$<input type="text" name="ship" value="30" readonly>
<br>
<INPUT name=box7>
<p>
<input type="button" value="Click to see results" onClick="UseIt()">
</FORM>
</BODY>
</HTML>
"lotto1.box7.value =
fdp(lotto1.ammount.value, 2)"