ideasworking
Programmer
Hello,
I could use a little help with a function. I wrote a function that should update the value in a text box named "CityUsage" depending on the state of a checkbox However the code just isn't working. Can someone help me identify the problem?
Here's my function...
I call the function from the keyup event of a text box as shown below. I put 1 in the call to the function for testing purposes.
I think the actual call to the function should be something like this... but maybe not???
I could use a little help with a function. I wrote a function that should update the value in a text box named "CityUsage" depending on the state of a checkbox However the code just isn't working. Can someone help me identify the problem?
Here's my function...
Code:
<script language="JavaScript">
function cc(a)
{
var PreviousValue = 771970
if (a=1)
{document.forms["WaterReadings"].CityUsage.value= document.forms["WaterReadings"].NewCityWaterReading.value - PreviousValue}
else
{document.forms["WaterReadings"].CityUsage.value= document.forms["WaterReadings"].NewCityWaterReading.value - PreviousValue + 1000000}
}
I call the function from the keyup event of a text box as shown below. I put 1 in the call to the function for testing purposes.
Code:
<input name="NewCityWaterReading" type="text" id="NewCityWaterReading" onKeyUp="cc(1)" value="771970" maxlength="10" align="right">
I think the actual call to the function should be something like this... but maybe not???
Code:
<input name="NewCityWaterReading" type="text" id="NewCityWaterReading" onKeyUp="cc(<?PHP echo "document.forms["WaterReadings"].Checkbox.value" ?>)" value="771970" maxlength="10" align="right">