i have currently 3 checkboxes.
But the thing is i only want 2 of them to b processed i.e

if check box 1 is checked then the 2 one must get blocked thus by preventing the user to check it.
similarly vice versa.
(this must be applied only to 1st 2 check boxes not the 3rd one )

Is there ne way to do it dynamically....?

Recommended Answers

All 5 Replies

You would probably need to use JavaScript or AJAX for that

leviathan is right, this would be easiest to do with a simple javascript function:

function disableCheckBox(checkbox1, checkbox2)
{
if (document.getElementById(checkbox1).checked == true)
{
document.getElementById(checkbox2).disabled = true;
} else {
document.getElementById(checkbox2).disabled = false;
}
}

and then for your checkboxes:

<input type="checkbox" id="chk1" onchange="disableCheckBox('chk1','chk2')" />
<input type="checkbox" id="chk2" onchange="disableCheckBox('chk2','chk1')" />

y can't use two radio buttons and one check box which is disabled

commented: apology for repeating your answer +3

Well i am complete navie in the field of java scripting ....
But seems like i have no choice but to learn it.

<label for='this'>related this </label><input type='radio' id='this' name='oneonly' value='single'><br>
<label for='that'>related that </label><input type='radio' id='that' name='oneonly' value='double'><br>
<label for='unrelated'>unrelated</label><input id='unrelated'type='checkbox' name='unrelated' value='lots'>

no javascript required

**edit** sorry Manuz, just read posts and saw your prior answer

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.