Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checkbox 1

Status
Not open for further replies.

mayamanako

Technical User
Aug 31, 2005
113
GB
hi guys,

i have 4 checkboxes, e.g.

checkbox1, checkbox2, checkbox3 and checkbox4

if i click the first 3 checkboxes, i want the 'checkbox4' to be checked automatically.

how do i do that? can you please give me some tips?

thanks.
 
You can use the onClick events of the 3 check boxes needed, to see if all are checked and act accordingly. Something like this should work:

Code:
function check_4(){
 var check1=document.getElementById('checkbox1');
 var check2=document.getElementById('checkbox2');
 var check3=document.getElementById('checkbox3');
 var check4=document.getElementById('checkbox4');

 if(check1.checked==true && check2.checked==true && check3.checked==true){
   check4.checked=true;
  }
}

<input type=checkbox id="checkbox1" onClick="check_4();">
...

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top