Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How can we set the indeterminate state of checkbox using javascript?

Checkboxes have three state checked, unchecked and indeterminate, first two have default behavior.

user-image
Question added by irfan shaikh , Consultant : Senior Web Designer/Front end Developer , Client : ● Impact Proximity, Dubai ● Cube Solution, Dubai ● WAC, Sharjha ● KIOEC, Kuwait ● IRIS Ltd.
Date Posted: 2013/10/21
Kariem Soudy
by Kariem Soudy , Web Solutions Consultant , Tatweer Educational Transportation Services Company

try this

 

<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js?ver=3.6.1'></script>

 

<input id='chk' type='checkbox' />

 

<script type='text/javascript'>

$(document).ready(function(){

$('#chk').click(function(){

 

if (this.readOnly==true){

this.checked=false;

this.readOnly=false;

}

else if (this.checked==false){

this.indeterminate=true;

this.readOnly=true;

}

 

});

});

</script>

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.