/    Sign up×
Community /Pin to ProfileBookmark

Auto Fill of Fields

I am trying to get a popup on my form that appears when a user clicks a particular radio button. I would like the popup to have 3 text fields asking for particular information that relates to the radio button, and then when they click enter it would populate those fields on the form. I found a script named FieldExplanation that comes CLOSE, but not exactly.

Right now, I just have an alert appear telling the user what fields needs completion when they click that radio button.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@oleragDec 12.2003 — Couple questions first...

  • 1. Is this new window with the three validation fields an

    existing html file that the parent will call OR do you want

    the parent to automatically open a new window and fill

    out all of the html?


  • 2. How many radio buttons are in the group in the parent

    window?


  • 3. When the validation is successful from the "child"

    window, what do you want to happen? I assume that if the

    validation fails (all three fields must be entered?) that focus

    remains in the "child" window.


  • Answer those questions and then give me a couple minutes,

    OK?
    Copy linkTweet thisAlerts:
    @TVanBuskauthorDec 12.2003 — To make it easier to understand ... here is the form: http://128.186.56.165:521/IMR_Form2.html

  • 1. I don't have an existing html page, I was thinking it would autogenerate (as the FieldExplanation script does at http://javascript.internet.com/forms/field-explanation.html)


  • 2. It is the radio button called "Emergency (Blue Light)" .. and there are 17 buttons altogether on that field.


  • 3. I would like to ask for BL # (which will autopopulate the "Room" field) ... BL Address (which will autopopulate the Service Building (not listed) field) .... and BL Phone number (which will autopopulate the Phone Number Being Reported field).


  • Any help you can provide would be absolutely terrific!!
    Copy linkTweet thisAlerts:
    @oleragDec 12.2003 — Hopefully this might you....

  • 1. In Netscape 7+, running the secondary window is throwing

    a "security error" but everything is working. I don't know if

    you need to examine this problem or not.


  • 2. I only included two (2) radio groups with two (2) textfields

    and attempted to make the naming convention similar

    to your web page. If you need to add other textfields in the

    "child" window that doesn't exist in the parent, I recommend

    the use of "hiddens".


  • 3. I cut/copied from the JavaScript Source web site (which you

    previously provided) and modified. This site should be

    provided with credit for the implementation ideas.


  • 4. I would place validation in your main web page and not

    in the sub-window. Use it (the "sub") only for data-entry

    support - don't you agree??


  • [code=php]
    <html>
    <head>
    <script type="text/javascript">
    function explain(name, output1, output2) {
    if ( (document.myForm.rb1[1].checked) &&
    (document.myForm.rb1[1].value = "BL") ) {
    newwin = window.open('','','top=150,left=150,width=325,height=300');
    if (!newwin.opener) {
    newwin.opener = self;
    }
    with (newwin.document) {
    open();
    write('<html>');
    write('<body onLoad="document.form.box1.focus()"><form name=form>' + '<br>');
    write('<p>You may enter your ' + name + ' here and it will be copied into the form for you.');
    write('<p><center>' + 'Room Number' + ': <input type=text name=box1 size=25 onKeyUp=' + output1 + '=this.value>');
    write('<p><center>' + 'Report Number' + ': <input type=text name=box2 size=15 onKeyUp=' + output2 + '=this.value>');
    write('<p><input type=button value="Click to close when finished" onClick=window.close()>');
    write('</center></form></body></html>');
    close();
    }
    }
    }
    </script>

    </head>
    <body>
    <form name="myForm">
    Room Number
    <input type="text" name="RoomNbr" size=25>
    <br>
    Number Being Reported
    <input type="text" name="ReportNbr" size=15>
    <p>
    Some more information
    <p>
    <input type="radio" name="rb1" value="DORM">Emergency (Dorm Entrance)
    <br>
    <input type="radio" name="rb1" value="BL" onChange="explain('Information','opener.document.myForm.RoomNbr.value','opener.document.myForm.ReportNbr.value')">Emergency (Blue Light)
    <br>
    </form>
    </center>
    </body>
    </html>
    [/code]
    Copy linkTweet thisAlerts:
    @TVanBuskauthorDec 12.2003 — Wow! That was quick!! I will give that a try and let you know. Thank you SO much!!
    Copy linkTweet thisAlerts:
    @oleragDec 12.2003 — That "security error" I mentioned was actually a "message"

    and not an error. Maybe my browser setting in Net7 is

    causing this - don't know.

    Good luck....
    ×

    Success!

    Help @TVanBusk spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.21,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...