I know better than asking this on our PHP board.
But none of the JS boards will answer...
Here's the deal I have several fields being updated for a parking structure... The client inputs the number of cars and can immediately see the percentage before updating the database....
I found this code online, but I need to do this dynamically for hundreds of lots...
Here's an example that works for one lot:
<HEAD>
<script type="text/javascript">
<!-- Begin
function startCalc(){
interval = setInterval("calc()",1);
}
function calc(){
one = document.autoSumForm.firstBox.value;
two = document.autoSumForm.secondBox.value;
document.autoSumForm.thirdBox.value = (one 1) / (two 1);
}
function stopCalc(){
clearInterval(interval);
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<form name="autoSumForm">
<input type=text name="firstBox" value="1000" onFocus="startCalc();" onBlur="stopCalc();"> /
<input type=text name="secondBox" value="" onFocus="startCalc();" onBlur="stopCalc();"> =
<input type=text name="thirdBox">
Here is an example of what I tried to get to work:
I'm not a javascript geek so any help is appreciated...
<HEAD>
<script type="text/javascript">
<!-- Begin
function startCalc(number){
interval = setInterval("calc("+number+")",1);
}
function calc(number){
field1 = "firstBox"+ number;
field2 = "document.autoSumForm.secondBox"+ number + ".value";
x = document.autoSumForm.field1.value;
document.autoSumForm.getElementById('field1').value
alert(document.autoSumForm.getElementById('field1').value );
//document.autoSumForm.thirdBox"+ number + ".value = (field1 1) / (field2 1);
// one = document.autoSumForm.firstBox+number+.value;
// two = document.autoSumForm.secondBox+number+.value;
// document.autoSumForm.thirdBox+number+.value = (one 1) / (two 1);
}
function stopCalc(number){
clearInterval(interval);
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<form name="autoSumForm">
<input type=text name="firstBox1" value="1000" onFocus="startCalc(1);" onBlur="stopCalc();"> /
<input type=text name="secondBox1" value="" onFocus="startCalc(1);" onBlur="stopCalc();"> =
<input type=text name="thirdBox1">
<br>
<input type=text name="firstBox2" value="1000" onFocus="startCalc(2);" onBlur="stopCalc(2);"> /
<input type=text name="secondBox2" value="" onFocus="startCalc(2);" onBlur="stopCalc(2);"> =
<input type=text name="thirdBox2">
<br>
As you can see I'm completely lost...
Thanks for any help...