|
Checkbox and textbox relationship.....
hi there guys,
just want to ask some help with regards to my javascript problem. I have a listing of multiple checkbox and hidden textbox beside of it and want to disable the checkbox in case the textbox contains no value. What I want is to used only single id or name for checkbox and textbox, as I tried it on a single line, it works fine, but as i add new line with same checkbox and textbox ID/name then the problem happens.
here's my attemp:
<html>
<head>
<title>Test Page</title>
<script>
function CheckMe ()
{
if
(document.getElementById('2').value=="")
document.getElementById('1').disabled = true;
else
document.getElementById('1').disabled = false;
}
</script>
</head>
<body onload="CheckMe ()">
<form >
<p><input type="text" name="testbox" id="2" size="20"><input type="checkbox" name="checkboxtest" id="1" value="ON"></p>
<p><input type="text" name="testbox" id="2" size="20" value=""><input type="checkbox" name="checkboxtest" id="1" value="ON"></p>
</form>
</body>
</html>
regards,
Chrissy
|