| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Can someone give some sample code
Hi,
I am building a form that has some text fields in which some amount can be entered.At the end of all this i have a grand total field. As I enter amounts in these text fields, I should be able to see the grand total added up and displayed in the grand totals field.Is there any way to do this in asp or should I use some other. Thanks. |
|
#2
|
||||
|
||||
|
You can do it like this
Code:
<script language="JavaScript">
function addValues()
{
var num1 = document.form1.num1.value * 1;
var num2 = document.form1.num2.value * 1;
var num3 = document.form1.num3.value * 1;
var total = num1 + num2 + num3;
document.form1.txtTotal.value = total;
}
</script>
<body>
<form name="form1">
Num1: <input type="text" name="num1"><br>
Num2: <input type="text" name="num2"><br>
Num3: <input type="text" name="num3"><br>
Total: <input type="text" name="txtTotal" readonly="true"><br><br>
<input type="button" name="AddValues" value="Add Values" onClick="addValues()">
</form>
</body>
|
![]() |
| Viewing: ASP Free Forums > Programming > Code Bank > Can someone give some sample code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|