javascript - How to set unchecked checkbox 1 When checkbox 2 was checked and set unchecked checkbox 2 When checkbox 1 was checked using script? -


how set unchecked checkbox 1 when checkbox 2 checked , set unchecked checkbox 2 when checkbox 1 checked

( make checkbox working radio button. )

<input type="checkbox" id="checkbox1" name="checkbox1" value="checkbox1"/> checkbox 1  <br> <input type="checkbox" id="checkbox2" name="checkbox2" value="checkbox2"/> checkbox2  <script type="text/javascript"> document.getelementbyid('checkbox1').onchange = function() {     document.getelementbyid('checkbox2').unchecked = this.checked;  }; </script>  <script type="text/javascript"> document.getelementbyid('checkbox2').onchange = function() {     document.getelementbyid('checkbox1').unchecked = this.checked;  }; </script> 

you need use .checked , not unchecked , set property false

document.getelementbyid('checkbox2').checked = false; 

fiddle


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -