How do I use Javascript to populate a text field based on a selection from a drop down box?

Greetings,
I have virtually no experience with JavaScript and I am trying to figure out how to add some basic automation features to an Adobe form.  I have a drop down box called "Hospital_Name" that will contain approximately 7 possible selections.  When the user makes a selection, I would like to have the text field (called "Hospital_Address") below the drop down box populate with the corresponding address for the selection.  I have the "Hospital_Address" text field configured for multiple lines and would like the address to have a line break between the street address and the city/state/zip.
For example, if the user selected "Hospital 1", the text field would display:
123 Main St
Anytown, CA 12345
Any help or examples you can provide would be greatly appreciated.

You have the element names within the object within brackets.
Make sure your brackets are properly placed and matched.
// Place all pre-population data into a single data structure
var Location = {
"--Hospital--":{ line1: " ", line2: " " },
"Bellevue Medical Center":{ line1: "2500 BMC Drive", line2: "Bellevue, NE 68123" },
"CHI Bergan Mercy":{ line1: "7500 Mercy Road", line2: "Omaha, NE 68124" }, 
"CHI Immanuel":{ line1: "6901 N. 72nd Street", line2: "Omaha, NE 68122" }, 
"CHI Lakeside":{ line1: "16901 Lakeside Hills Court", line2: "Omaha, NE 68130" }, 
"CHI Midlands":{ line1: "11111 S. 84th Street", line2: "Papillion, NE 68046" },
"Creighton University Medical Center":{ line1: "601 N. 30th Street", line2: "Omaha, NE 68131" },
"Nebraska Medical Center":{ line1: "4400 Emile Drive", line2: "Omaha, NE 68105" }
// some debugging code to see location names;
console.show();console.clear():
for(I in Location) {
console.println(I);
// end debugging code;
function SetFieldValues(Hospital_Name) {
    this.getField("AddLine1").value = Location[Hospital_Name].line1;
    this.getField("AddLine2").value = Location[Hospital_Name].line2;
This is not a beginners task but requires a fair amount of knowledge about the structure of objects, defining strings, and structure of arrays.
Are you sure you have all the field names correctly spelled and capitalized?
Do you get any error in the JavaScript console?
Just trying the line that defines the "Location", I get the following error:
SyntaxError: invalid property id
1:Console:Exec
undefined
All the form field in a PDF are processed by using JavaScript and any error in any script will stop JavaScript processing.
It might help to have a link to the problem form.
Make sure your brackets are properly placed and matched.
// Place all pre-population data into a single data structure
var Location = {
"--Hospital--":{ line1: " ", line2: " " },
"Bellevue Medical Center":{ line1: "2500 BMC Drive", line2: "Bellevue, NE 68123" },
"CHI Bergan Mercy":{ line1: "7500 Mercy Road", line2: "Omaha, NE 68124" }, 
"CHI Immanuel":{ line1: "6901 N. 72nd Street", line2: "Omaha, NE 68122" }, 
"CHI Lakeside":{ line1: "16901 Lakeside Hills Court", line2: "Omaha, NE 68130" }, 
"CHI Midlands":{ line1: "11111 S. 84th Street", line2: "Papillion, NE 68046" },
"Creighton University Medical Center":{ line1: "601 N. 30th Street", line2: "Omaha, NE 68131" },
"Nebraska Medical Center":{ line1: "4400 Emile Drive", line2: "Omaha, NE 68105" }
function SetFieldValues(Hospital_Name) {
    this.getField("AddLine1").value = Location[Hospital_Name].line1;
    this.getField("AddLine2").value = Location[Hospital_Name].line2;

Similar Messages

  • Populate second drop down box based on selection from first drop down box

    Hello, I have a situation involving a drop down box with 9 items to choose from. What I want to do is depending on which of the 9 items the client chooses, this will determine what items are populated in the second drop down boxes (the items in the second drop down box will be mirrored on 9 other drop down boxes).
    For example, my first list box would be titled Review Type and there would be MF, VA, FA, etc. If the MF was selected, then the 10 boxes below (all drop-downs) will be prepopulated with a specifc selection of topics and if they chose VA then another set of topics would be prepopulated.
    Can you please point me out on the proper script to accomplish this? I don't have a xml/data source to connect to so I will be manually inputting the choices.  Thanks!
    Header 1
    Header 2

    I came across a sample of a script that seems to do what I want it to however I can't seem to get it to work all the way through.  It only compiles the items from the 1st case and not the 2nd or 3rd case.  If I click on the 1st case, it will not clear if I click on the 2nd or 3rd case. The items from the 1st case stays static and shows up for other cases.  However if I open the form and click on the 2nd or 3rd case first, it's blank and nothing shows up. Can you please help me out with any fixes to this problem?  Please help!!
    Here's the script:
    switch (this.rawValue){
    case "General Client File Review":
    ft1.clearItems();
    ft1.rawValue
    = null;ft1.addItem("UBIS New Account Application");
    ft1.addItem("Suitability Update Form");
    ft1.addItem("Trust Certification Form");
    ft1.addItem("Corporate Account Form");
    ft1.addItem("Partnership Account Form");
    ft1.addItem("LLC Account Form");
    break; 
    case "529 Plan":
    ft1.clearItems();
    ft1.rawValue
    = null;ft1.addItem("UBIS New Account Application");
    ft1.addItem("Suitability Update Form");
    ft1.addItem("Trust Certification Form");
    ft1.addItem("Corporate Account Form");
    ft1.addItem("Partnership Account Form");
    ft1.addItem("LLC Account Form");
    ft1.addItem("529 College Plan Disclosure");
    ft1.addItem("Vendor Application");
    ft1.addItem("Fund Direct Addition Form");
    ft1.addItem("Investment Replacement Form");
    ft1.addItem("RT Transaction Approval");
    break; 
    case "Direct Held Mutual Fund":
    ft1.clearItems();
    ft1.rawValue
    = null;ft1.addItem("UBIS New Account Application");
    ft1.addItem("Suitability Update Form");
    ft1.addItem("Trust Certification Form");
    ft1.addItem("Corporate Account Form");
    ft1.addItem("Partnership Account Form");
    ft1.addItem("LLC Account Form");
    ft1.addItem("Mutual Fund Disclosure");
    ft1.addItem("FINRA MF Expense Analyzer");
    ft1.addItem("Vendor Application");
    ft1.addItem("Fund Direct Addition Form");
    ft1.addItem("Investment Replacement Form");
    ft1.addItem("RT Transaction Approval");
    break;}

  • How to get my usernames to appear from the drop down box then password automatically put in?

    =( ugh...
    I used to have my settings where it remembered my user name from the drop down box - so I would just type the first letter of my user name and a drop down box would appear and I could just click on my user name for that particular site and my password would automatically fill in...
    I changed something the other night and can't remember what the heck I did... now it won't remember ANY user name OR password or like on face book it has my user name and password there automatically when I open up the log in face book page.
    So I would like to know if anyone knows what needs to be clicked and unclicked to make it so:
    I start typing my user name and the drop down box appears with user names and then my password automatically fills.. I DO NOT want all my user names and passwords already IN the forms when I first open the website... but for me to actually type in a letter and then it fills it... like it used to =(
    /cry
    why do I touch stuff?
    Anyway I hope someone can help me because I am going nuts trying to figure it out and think I'm goofing things up even more =/
    I have firefix 3.6.10

    Does this help?
    * http://kb.mozillazine.org/Password_only_filled_after_entering_user_name
    * Make sure that you not run Firefox in (permanent) [[Private Browsing]] mode
    * You enter Private Browsing mode if you select: Tools > Options > Privacy > History: Firefox will: "Never Remember History"
    * To see all History and Cookie settings, choose: Tools > Options > Privacy, choose the setting <b>Firefox will: Use custom settings for history</b>
    * Uncheck: [ ] "Automatically start Firefox in a private browsing session"

  • How to capture the value selected in the drop down box

    Hi all,
    I am populating values in  drop down box by using FM vrm_set_values in module pool.
    like below
    01  ABC
    02 ACB
    03 BCA
    04 CAB
    in module pool drop down box element name is RQGM-VALUE.
    Problem is what ever the value is select in the drop down box from above element RQGM-VALUE is not filling any value.
    i need to capture the value selected in the drop down box and pass it to another variable.

    Hi,
    Refer this standard code. Your issue will be resolve.
    REPORT demo_dynpro_dropdown_listbox.
    TYPE-POOLS vrm.
    DATA: name  TYPE vrm_id,
          list  TYPE vrm_values,
          value LIKE LINE OF list.
    DATA: wa_spfli TYPE spfli,
          ok_code TYPE sy-ucomm,
          save_ok TYPE sy-ucomm.
    TABLES demof4help.
    name = 'DEMOF4HELP-CONNID'.
    CALL SCREEN 100.
    MODULE cancel INPUT.
      LEAVE PROGRAM.
    ENDMODULE.
    MODULE init_listbox OUTPUT.
      CLEAR demof4help-connid.
      SELECT  connid cityfrom cityto deptime
        FROM  spfli
        INTO  CORRESPONDING FIELDS OF wa_spfli
       WHERE  carrid = demof4help-carrier2.
        value-key  = wa_spfli-connid.
        WRITE wa_spfli-deptime TO value-text USING EDIT MASK '__:__:__'.
        CONCATENATE value-text
                    wa_spfli-cityfrom
                    wa_spfli-cityto
                    INTO value-text SEPARATED BY space.
        APPEND value TO list.
      ENDSELECT.
      CALL FUNCTION 'VRM_SET_VALUES'
           EXPORTING
                id     = name
                values = list.
    ENDMODULE.
    MODULE user_command_100.
      save_ok = ok_code.
      CLEAR ok_code.
      IF save_ok = 'CARRIER' AND NOT demof4help-carrier2 IS INITIAL.
        LEAVE TO SCREEN 200.
      ELSE.
        SET SCREEN 100.
      ENDIF.
    ENDMODULE.
    MODULE user_command_200.
      save_ok = ok_code.
      CLEAR ok_code.
      IF save_ok = 'SELECTED'.
        MESSAGE i888(sabapdocu) WITH text-001 demof4help-carrier2
                                            demof4help-connid.
      ENDIF.
    ENDMODULE.

  • Selection from one Drop down populates a second drop down list

    I have a form connected to a database. The database contains columns for project number, name, company name, address, etc.
    The first drop down I would select a distinct project number, once selected I'd like the second drop down to contain a selection set of all the companies assigned to that distinct project number.
    I'm assuming that this is possible?
    Thanks,
    Todd

    Thanks Paul,
    The 4th example in the Webinar is what we used to auto populate a users contact information when selecting their name from a drop down list. This name drop down has all the names in a particular table of the data base, we would like to filter that down by first selecting a project number from a drop down list which would cause the names to filter down to just those associated with the project number picked.
    Is there scripting that can be done that can accomplish this? We can get a single name to show in the drop down but it doesn't seem to want to return a list. Any thoughts?
    Thanks,
    Todd

  • Create a drop down list that populates based on the selection form another drop down list.

    I need to set up a drop down list that is popualated (i.e. displays a certain list of selctions in the drop down list) based on the choise the form user selects in an adjacent List
    For example
    There are two drop down list field sitting side by side in the form
    1. Select State          2. Select Course
    What I want to do is have a list of states in the first drop down list (1.Select State) and depending on which state the form user selects , the second drop down list (2.Select Course) will populate with a selction of courses available in that selected state only (i.e. it will on;y show course available in QLD if QLD is selcted).
    Is this hard to do?

    Hi,
    I would recommend some posts from Stefan Cameron's blog:
    http://forms.stefcameron.com/2006/09/18/connecting-a-form-to-a-database/
    http://forms.stefcameron.com/2006/09/29/selecting-specific-database-records/
    http://forms.stefcameron.com/2006/12/18/databases-inserting-updating-and-deleting-records/
    http://forms.stefcameron.com/2006/12/07/better-form-design-with-xfa-25/
    Hope that helps,
    Niall

  • How do you auto-populate a text field based on entries in other text fields?

    I would like to be able to have a text field that populates as "Complete" or "Incomplete" based on whether all the mandatory text fields have been filled out or not.
    For example, if the "First Name," "Last Name," and "City" text fields are not filled out, the "completion status" text field will show "Incomplete" and once they are filled out, the "completion status" text field will turn into "Complete."
    How would I do this using javascript? I've searched the web for a tutorial, but most of the results seem to be dropdown-centric.
    Please point me in the right direction!

    Try the script below. I put this on the calculate event for Field1
    if(FirstName.rawValue == null || LastName.rawValue == null || City.rawValue == null){
    Field1.rawValue = "Incomplete"
    else
    Field1.rawValue = "Complete"

  • Do I need to use javascript to get a text field in a PDF form to aut fill with current/today's date?

    I have a form for booking appointments and would like the date field to automatically fill with
    today's date and to print. I have set the text field's format to "Date" and when I place the cursor into the
    date field, today's date shows. It disappears as soon as I tab to the next field.
    Does this action require a javascript script to fill and print today's date? If so, where do I find that?
    Or is there another way to format the text field (besides typing today's date) to get the current date?
    Thanks.
    Ali
    using iMac 2.93 GHz Intel Core 2 Duo 8 GB | OS Snow Leopard 10.6.8 | Acrobat Pro 8

    Thank you GKaiseril!
    From the examples by Chris Dahl, I edited the script in the text field editing dialog to reflect the title I had given the field. That fixed the problem of today's date disappearing as soon as I tabbed to the next field.
    How do I choose for document level or page open script? I would like it to insert the date upon opening the document.
    Thanks again.
    Ali
    NOTE: I found the answer within Chris Dahl's tutorial... path is for Acrobat Pro 8: Advanced>Document Processing>Document Javascripts

  • Using Javascript to show/unshow a field based on input in another field

    I want to display/not display a field in a JSP depending on what is selected in another field.
    I am using <div></div> element currently which is displayed/not displayed using a Javascript invoked by the first field.
    the problem with div is that I have to put it inside a <tr><td> otherwise it doesn't work. This makes the field look aloof from the rest of the page, and is also not aligned with the other fields.
    Is there anything other than <div> that can be used? or is there a way to correct the look of the field inside a div?
    Thanks

    You shouldn't have to put it inside a <tr><td> to get it to work. I've done what you are trying to do with <span></span> and it worked fine. I haven't tried it with a <div> but I can't image why that wouldn't work. Maybe you could post your code.

  • Using Javascript to change multiple text field names

    I have a pdf with multiple text fields. I need to change all the text field names (General -> Name) so that they are unique so that when I combine multiple pdfs together, the text fields will stay intact. Is there anyway to do this using javascript? Thanks!

    I'm new to javascript too...it will be very helpfull for me too...Thanks
    poltrone
    prodotti chimici

  • HELP! Script to populate a text field based off of whats picked in a dropdown on a previous page?

    Alright hopefully i can explain this good enough.
    I have a dropdown box that has two different options to pick from.  For example:
    Dropdown1 has:  Option A
                             Option B
    On the other page I have two text fields.  TextField1 just shows whatever is picked from the Dropdown1 (Option A or Option B).  TextField2 needs to do the following:  If Option A is picked i just need the field to stay blank.  If Option B is picked i need it to populate specific text.
    I thought i figured out a way to do this but it seems that since it is on a different page the script will not fire.
    Any help is much appreciated!!!!!!

    Hi,
    With the first issue: having the dropdown and the first textfield displaying the same value, the easy solution is to use Global Binding.
    Make sure that the dropdown and the first textfield have the same name in the hierarchy.
    The select one of them and in the Object > Binding palette, set the binding to Global.
    In the dropdown go to the Object > Binding palette and make sure that "Specify values" is NOT ticked.
    It is probably a good idea to set the textfield to read only, in the Object > Value palette. This would prevent the user overwriting the value set by the dropdown.
    No script required. Whatever is in the dropdpwn will appear in the textfield.
    The second issue needs a small script in the calculate event of the second textfield. This looks at the value in the first textfield (TextField1) and sets its own value. This is JavaScript:
    if (TextField1.rawValue == "Option B")
         this.rawValue = "Specific text";
    else
         this.rawValue = null;
    There are some examples here: http://assure.ly/jtTkdO, http://assure.ly/fYCuQ2.
    Hope that helps,
    Niall

  • How do i create a drop down menu for selecting from the drop down arrow

    how can i create a drop down menu so that when i click on the arrow in the cell i can select from the menu that appears

    katiesandell wrote:
    how can i create a drop down menu so that when i click on the arrow in the cell i can select from the menu that appears
    Hi Katie,
    Welcome to Apple Discussions and the Numbers '09 forum.
    Numbers vocabulary for this feature is a "Pop-up Menu". It's available as a Cell Format, and is set and edited in the Cell Format Inspector.
    See "Using a Checkbox, Slider, Stepper, or Pop-Up Menu in Table Cells" starting on page 96 of the Numbers '09 User Guide.
    This guide, and the equally useful iWork Formulas and Functions User Guide are available for download through the Help menu in Numbers.
    Regards,
    Barry

  • Form2mail how do I set up the form to sent to a recipient selected from a drop-down menu?

    I am trying to configure dreamweaver form2mail to be able to send the information submitted to individual employees.  I would like the form to be set up where as you choose the recipient form a drop down menu and the only that recipient would receive the information collected on the form.  I can't seem to find any information on this.  I can only find info on sending to multiple recipients at the same time.  I only want the recipient that is selected to receive the form information.
    Alternatively, can anyone recommend a low cost or FREE form to mail system.
    Thanks in advance for your assistance!

    Jim, That is exactly what I need.  I'm using Form2Mail the Dreamweaver extension for Adobe Dreamweaver.  It only gives me the option to send to one email address or cc to multiple not individual sends.
    Here is the html
    <form action="/HDWForm2Mail/Form2Mail.php" method="post" enctype="multipart/form-data" name="form1" id="form1" accept-charset="iso-8859-1">
            <p>
              <label for="message"></label>
              <textarea name="message2" id="message" cols="50" rows="5"></textarea>
            </p>
            <table width="429">
              <tr>
                <td><strong>Recipient:</strong></td>
                <td><label for="recipient"></label>
                  <select name="recipient" id="recipient">
                    <option value="[email protected]">Mr. Person 1</option>
                    <option value="[email protected]">Mr. Person 2</option>
                    <option value="[email protected]">Mr. Person 3</option>
                  </select></td>
              </tr>
              <tr>
                <td><strong>Your Email Address:</strong></td>
                <td><label for="email"></label>
                  <input type="text" name="email" id="email" /></td>
              </tr>
              <tr>
                <td><strong>Attachment:</strong></td>
                <td><label for="file"></label>
                  <input type="file" name="file" id="file" /></td>
              </tr>
              <tr>
                <td colspan="2"><strong>To Submit your email, click the SEND button:
                  <input name="send" type="submit" id="send" onclick="MM_validateForm('email','','RisEmail','message','','R');return document.MM_returnValue" value="Send" />
                </strong></td>
              </tr>
            </table>
            <input type="hidden" name="hdwemail" id="hdwemail" value="lisa+email.com" />
            <input type="hidden" name="hdwok" id="hdwok" value="http://ricochec.com/thank-you.html" />
            <input type="hidden" name="hdwnook" id="hdwnook" value="http://ricoche.com/error.html" />
          </form>

  • Populate a text filed based on LOV selection with AJAX

    Good day,
    I would like to populate a text box based on selection from a LOV. If someone selects a LOV value and then tabs off off of that element, I would like
    the text box populated from a sql statement based on the LOV value in the predicate.
    Application Express 4.1.1.00.23
    Thanks for any guidance.
    Steve

    Hi Steve,
    You can do that with an dynamic action which triggers on a "onchange" from the LOV.
    Regards,
    Kees Vlek
    <tt>Company: http://www.orcado.nl
    Blog: http://www.orcado.nl/blog/blogger/listings/69-kvlek
    Twitter: http://www.twitter.com/skier66</tt>
    If the question is answered please change it to answered and mark the appropriate post as correct/helpfull.

  • HT1918 Trying to make make account changes to my itunes account.  Receive error message regarding province "enter at most 3 letters" when the only option I have is to select from a drop down menu.  Cannot make changes to my account.  How do I get this fix

    As you can tell, this is my first post
    I am attempting to make changes to my itunes account, but when I hit done, an error message "enter at most 3 letters or numbers for province" appears.  I have not attempted to make any modificaitons to this field.  The only options I have for data in this field are picked from a drop down menu.  I have no idea why this msg is appearing.  Any ideas on why it is showing up?  Thanks.

    There seems to be at least one package that can't be located. See the message below from you log file
    Requesting locations synchronously for content SDC00003.2
    with priority Medium    ContentAccess    4/3/2015 1:30:51 PM    2644 (0x0A54)
    The number of discovered DPs(including Branch DP and Multicast) is 0    ContentAccess    4/3/2015 1:30:51 PM    2644 (0x0A54)
    My Blog: http://www.petervanderwoude.nl/
    Follow me on twitter: pvanderwoude

Maybe you are looking for

  • LaserJet Pro MFP M127fn Printer Driver Installation Failed

    Got a brand new, fresh out of the box, HP LaserJet Pro MFP M127fn. Failed to install the driver that came with it on my computer Windows 7 64-bit Home Premium. I downloaded latest driver (full version) and still failed to install. The installation st

  • Is there a way to permanently change the input language in the login screen?

    Whenever I start my iMac with Mavericks, after the boot is complete and the login window appears, I have the change the language in the top right corner from US to DE, else I can't type in my password. Mavericks does not remember this setting, next t

  • Will a bluetooth adapter work with AirPort

    Hey Ladies and Gents, If I were to buy a bluetooth adapter for an iPod Classic, will it communicate with an AirPort system? My main goal is to send music to my home stereo from my iPod wirelessly. Is this possible? Thanks for you help, Jason

  • No Microphone (!?) Any Recommendation?

    Hello all. My sister was using her Mac mini, and she was all excited when she used Skype to talk to her friend in England, only to realise there is no Mic on the Mac mini... So what kind of mic can we get for the mini? I know one way is the get iSigh

  • Drill down to another report

    Status     Model     Count A     Printer          5      Desktop          7      CPU          18 I     Printer          12      Desktop          34      CPU          66when i click/drill to Status Level i need to open another report and similarly for