Hi all In my form im having the contact address and delivery address fields if both fields have same address then i need the delivery address field to be auto filled. I will keep check box to enable this. can anybody suggest me in this regard regards manikandan
try this, hope it is what you need <script> function toggleSameAddress() { var checkbox = document.getElementById("sameAddress"); var contactAddress = document.getElementById("contactAddress"); var deliveryAddress = document.getElementById("deliveryAddress"); if(checkbox.checked) { deliveryAddress.disabled = true; deliveryAddress.value = contactAddress.value; } else { deliveryAddress.disabled = false; deliveryAddress.value = ""; } } </script> <body> <label for="contactAddress">Contact address</label> <input type="text" id="contactAddress"><br> <input type="checkbox" id="sameAddress" onclick="toggleSameAddress()"> <label for="sameAddress">same address</label> <br> <label for="deliveryAddress">Delivery address</label> <input type="text" id="deliveryAddress"> </body>