I have a problem with this simple Javascript code:
function select_checkbox(i)
{
switch(i)
{
case 3:
if (document.upload_form.3.checked=true)
{
document.upload_form.4.checked=true;
document.upload_form.4.disabled=true;
document.upload_form.5.checked=true;
document.upload_form.5.disabled=true;
}
if (document.upload_form.3.checked=false)
{
document.upload_form.4.checked=false;
document.upload_form.4.disabled=false;
document.upload_form.5.checked=false;
document.upload_form.5.disabled=false;
}
break;
[other code]
associated with this HTML code:
<input type="checkbox" name="3" onclick="select_checkbox(3)" />
<input type="checkbox" name="4" onclick="select_checkbox(4)" />
<input type="checkbox" name="5" onclick="select_checkbox(5)" />
I would like to do this:
- if I select the checkbox “3”, check and disable 4 and 5
- if I select the checkbox “4”, check and disable 3 + uncheck and disable 5
- if I select the checkbox “5”, uncheck and disable 3 and 4
- when unselected re-enable and uncheck all
The first part of the code (I report only the part of the checkbox “3”) works good but I have a problem with restore the configuration by un-check the checkbox.
that should be ==