|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
javascript math function
Can anyone help me modify the code seen here
http://javascript.internet.com/forms/auto-sum-form-boxes.html what I want to do is have a drop down box and three other fields called quantity price total in the drop down the selections would be per/m and ea if per/m is selected then I need to do this math function: quantity x's price devided by 1000 = total if ea is selected then quantity x's price = total can anyone tell me how to modify the code from the javasite to do this I know I need a switch statment thanks |
|
#2
|
|||
|
|||
|
RE: javascript math function
This?
Code:
<html>
<head>
<script language="javascript">
function startCalc(){
interval = setInterval("calc()",1);
}
function calc(){
one = document.autoSumForm.firstBox.value;
two = document.autoSumForm.secondBox.value;
per = document.autoSumForm.per.options[document.autoSumForm.per.selectedIndex].value;
if(per=="gr"){
one=one/1000;
}
document.autoSumForm.thirdBox.value = one * two;
}
function stopCalc(){
clearInterval(interval);
}
</script>
</head>
<body>
<form name="autoSumForm">
Qty.<input type=text name="firstBox" size="5" value="" onFocus="startCalc();" onBlur="stopCalc();">
@ $<input type=text name="secondBox" size="5" value="" onFocus="startCalc();" onBlur="stopCalc();">
<select name="per" id="per" onFocus="startCalc();" onBlur="stopCalc();">
<option value="ea">Each</option>
<option value="gr">Per/M</option>
</select>
=
$<input type=text size="5" name="thirdBox">
</form>
</body>
</head>
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > javascript math function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|