javascript - how to give "same as the above" in form entries -
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <form method="post" class="form-group"> <label>first name</label><input type="text" name="fname" class="form-control"> <label>last name</label><input type="text" name="lname" class="form-control"><br> <label>i ready</label><input type="checkbox" name="ch"><br><br> <label>address</label><input type="text" name="address" class="form-control"> </form><br><br> <form method="post" class="form-group"> <label>same above</label><input type="checkbox" name="chd"><br><br> <label>first name</label><input type="text" name="fname" class="form-control"> <label>last name</label><input type="text" name="lname" class="form-control"><br> <label>i ready</label><input type="checkbox" name="ch"><br><br> <label>address</label><input type="text" name="address" class="form-control"> </form>
when checked checkbox named 'same above' second form have take same values in first form fields.
you can use jquery suppose have 2 input fields , checkbox if click on checkbox has value first input , assign second like
$(function(){ ("#checkbox").click(function(){ if($(this).is(':checked')){ var input1=$("#input1").val(); $("#input2").val(input1); } }); });
Comments
Post a Comment