Hi!
I am trying to manipulate the value of an input box based on whether a checkbox is checked or not.
example
checked input = 1600 and enabled
unchecked input = 0 and disabled
I am having 2 problems:
1) When the page is loaded I get unchecked and input = 1600: it should be : either
checked input = 1600 and enabled
or
unchecked input = 0 and disabled
2) When the checkbox is checked for the 2nd time the input remains 0 it should go back to the initial value 1600
can anyone help me?
<script language="JavaScript">
<!--
function enable_text(status)
{
if (status== true){
var var_gate_request_original = document.f1.GateRequest0.value ;
document.f1.GateRequest0.disabled =false;
document.f1.GateRequest0.value = var_gate_request_original ;
}
if (status== false){
var var_gate_request_original = document.f1.GateRequest0.value ;
var var_gate_request_zero = 0 ;
document.f1.GateRequest0.value = var_gate_request_zero;
document.f1.GateRequest0.disabled =true;
}
}
//-->
</script>
<form name=f1 method='post'>
<table width="200" border="1">
<tr>
<td><input name="R1" type="checkbox" value="" onclick='enable_text(this.checked)'/></td>
<td><input name="GateRequest0" type="text" value="1600" /></td>
</tr>
</table>
</form>