auto fill text field

Discussion in 'PHP' started by mani4u, May 27, 2009.

  1. #1
    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
     
    mani4u, May 27, 2009 IP
  2. cont911

    cont911 Peon

    Messages:
    50
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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>
     
    cont911, May 28, 2009 IP