Uncheck a checkbox if another checked with javascript

后端 未结 5 1071
北恋
北恋 2020-12-21 09:48

I have two checkbox fields. Using Javascript, I would like to make sure only one checkbox can be ticked. (e.g if one checkbox1 is ticked, if checkbox2 is ticked, checkbox1 w

5条回答
  •  离开以前
    2020-12-21 10:35

    
    

    Note that I am using onclick event:

    function setFries(obj){
       var fries = document.getElementsByName('fries');
       if(obj.id =='hotdog') //Or check for obj.type == 'radio'
       {
          for(var i=0; i

提交回复
热议问题