Hello Guys
This Tutorial will guide you for Changing the value of dynamic or multiple checkbox and radio buttons when select or unselected to them.
For better understand I am writing example. Please follow below steps :
Step 1 : Create index.html and put below code.
<p>CheckBox's</p><br>
Click 1 <input type="checkbox" value="" onchange="shift(this.id,'1');"/><br>
Click 2 <input type="checkbox" value="" onchange="shift(this.id,'3');"/><br>
Click 3 <input type="checkbox" value="" onchange="shift(this.id,'4');"/><br>
Click 4 <input type="checkbox" value="" onchange="shift(this.id,'5');"/><br>
Click 5 <input type="checkbox" value="" onchange="shift(this.id,'6');"/><br>
Click 6 <input type="checkbox" value="" onchange="shift(this.id,'7');"/><br>
<br><br>
<p>Radio Button's</p><br>
Click 1 <input type="radio" value="" onchange="shift(this.id,'1');"/><br>
Click 2 <input type="radio" value="" onchange="shift(this.id,'3');"/><br>
Click 3 <input type="radio" value="" onchange="shift(this.id,'4');"/><br>
Click 4 <input type="radio" value="" onchange="shift(this.id,'5');"/><br>
Click 5 <input type="radio" value="" onchange="shift(this.id,'6');"/><br>
Click 6 <input type="radio" value="" onchange="shift(this.id,'7');"/><br>
Step 2 : Put below javascript code in index.html.
<script>
function shift(id,value) {
if($("#"+id).val()!='false')
{
$("#"+id).val(value);
}
else
if($("#"+id).val()=='false')
{
$("#"+id).val(false);
}
}
</script>
Thank You.
0 Comment(s)