Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to change value of multiple checkbox and radio buttons?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 715
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: