I have 5 check box in my HTML (JSP). Out of those 5, at a time only 1 could be selected. So if I click on one check box, other 4 should be disabled. This is true for all the 5 check boxes.
var A= document.getElementById("A");
var B= document.getElementById("B");
var C= document.getElementById("C");
var D= document.getElementById("D");
var E= document.getElementById("E");
if(document.getElementById("A").checked == true){
eval("B.disabled = true");
eval("C.disabled = true");
eval("D.disabled = true");
eval("E.disabled = true");
} else {
eval("B.disabled = false");
eval("C.disabled = false");
eval("D.disabled = false");
eval("E.disabled = false");
}
This code is only for check of 'A' field. To do this for all 5 fields, I need to repeat this code 5 times.
Any better suggestions?
var A= document.getElementById("A");
var B= document.getElementById("B");
var C= document.getElementById("C");
var D= document.getElementById("D");
var E= document.getElementById("E");
if(document.getElementById("A").checked == true){
eval("B.disabled = true");
eval("C.disabled = true");
eval("D.disabled = true");
eval("E.disabled = true");
} else {
eval("B.disabled = false");
eval("C.disabled = false");
eval("D.disabled = false");
eval("E.disabled = false");
}
This code is only for check of 'A' field. To do this for all 5 fields, I need to repeat this code 5 times.
Any better suggestions?