dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Check Box to autofill other fields

  1. #1
    Join Date
    May 2012
    Posts
    1

    Check Box to autofill other fields

    Hi have a form that has 2 different sections. First section is Business Address the 2nd is the Mailing address. I would like to get a script that I can add to my form that will add a Check Box with the following words: Click here if same as Business Address. When the client click the Check Box it will then auto fill the Mailing address with the Business Address.

  2. #2
    Join Date
    Feb 2012
    Location
    Bokaro Steel City (Jharkhand), India!
    Posts
    194
    HTML Code:
    <fieldset>
        <legend>Form</legend>
        <form name="_form">
            <label> Business Address: </label> <br/>
                <textarea name="_addr_busi"></textarea> <br/>
            <label> Mailing Address: </label> <br/>
                <textarea name="_addr_mail"></textarea>
            <label> <input type="checkbox" name="_checkbox" onclick="copy()" /> Click here if same as Business Address!</label>
        </form>
    </fieldset>
    
    <script>
        var copy = function () {
            if(document.forms['_form'].elements['_checkbox'].checked == true) {
                document.forms['_form'].elements['_addr_mail'].value = document.forms['_form'].elements['_addr_busi'].value;
            } else {
                document.forms['_form'].elements['_addr_mail'].value = '';
            }
        }
    </script>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles