How to populate a dropdown box based on a selection in another Dropdown box.

I am trying to find out a way to do the following:
I am using coldfusion ....working on a form. The form has
couple of dropdown boxes. Based on the selection on the first
dropdown box another dropdown box needs to get populated with
different options. These options will be coming from a query. I am
trying to find out the Javascript code for doing this.
Thanks in advance.

jchopra,
There's a method to doing what you're wanting to do that I've
used extensively.
Basically, within my code, I start by invoking the method
that returns the data for the dropdown lists. Then, I use the
following code to pour the data returned into a javascript array:
var locArray = new Array(#evaluate(locs.recordcount+1)#);
locArray[0] = new Array('','','','','','','','','',);
<cfloop query="locs">
locArray[#locs.CurrentRow#] = new
Array('#JSStringFormat(locationId)#',
'#JSStringFormat(fkyPolicyId)#',
'#JSStringFormat(locationNumber)#',
'#JSStringFormat(description)#',
'#JSStringFormat(address1)#',
'#JSStringFormat(address2)#',
'#JSStringFormat(zipcode)#',
'#JSStringFormat(city)#',
'#JSStringFormat(state)#';
</cfloop>
Then I wrote a javascript function that is assigned to the
first dropdown's onChange() event. When the user changes the value
that is selected within the dropdown, I use javascript to locate
(using the policyid) the corresponding record in the javascript
array and populate and/or select the appropriate value(s) in the
second dropdown.
If the data returned from the method invocation is too large
to use within a javascript array, you may need to limit the results
that are returned.
Hope this makes sense. If not, please let me know.
ds

Similar Messages

  • How do I populate one dropdown list based on the selection in another dropdown list?

    I have one dropdown list that has 21 choices.  Depending on the selection of those 21 choices, I have another dropdown list that will select a different subset of choices from a pool of 96 choices.  How do I get this to happen?

    I have one dropdown list that has 21 choices.  Depending on the selection of those 21 choices, I have another dropdown list that will select a different subset of choices from a pool of 96 choices.  How do I get this to happen?

  • Fill a combo box based on the selection of another combo box

    Hi All,
    I am new to jsp & java script. I have a arraylist of communities and there are 2 combo boxes meant for source community & destination community.
    First user will select Source community , after that I've to remove that community from list and display the option for destination community combo box.
    Here the problem is I am getting the source community value in a java script function - "checkSource() " which I've written at the "onClick" of source community.
    Now java script variable has that community & list of community is a java variable, so I am not able to remove that community from java list.
    Please suggest in the same.
    I've written like this -
    function checkSource()
         var selIndex = document.targetForm.srcgroupname.selectedIndex;
    var srcCommunity = document.targetForm.srcgroupname.options[selIndex].value;
    alert("Selected Src Community-"+srcCommunity);
         <%
         alert("Community length-"+community.size());
         community.remove(community.getIndex( %> srcCommunity <%));
         alert(community.size());
         %>
    But this is not working. community is a java list.
    Please help....
    Thanks in Advance
    Sneha

    Do it with AJAX. Here -> http://www.iem.pw.edu.pl/~opalam/sample/TestAJAX.zip You can download a small, sample project that presents AJAX.
    In the project Servlet, Gson and Jquery is used. When onchange is fired in the first select box a js script method is invoked. This method uses ajax to get the json (gson is used to transfer java objects to json) data from the servlet depending on the value of selected option. When data are obtained the second select box is populated. Of course it might be written better but the general idea is clearly visible which was my goal. Hope this helps.

  • Pre-Populate Dropdown based on information selected in another dropdown

    Hello,
    I hope this make since. I am working on building a form using Adobe Livecycle Designer. I have a dropdown list in multiple fields on the same form that will have the same information selected. I want the additional fields to automatically populate the information a user selects in the first dropdown list. Is this possible ??? If so, what would be the script/code necessary to do so ??? Thank you for your help.
    Example
    City, State appears in 4 different fields based on the selection in field 1, the additional 3 fields auto-populates the same information.
    Field/List 1: New York, NY <-- Selected City, State
    Field/List 2: New York, NY <-- Auto Populated based on field 1
    Field/List 3: New York, NY <-- Auto Populated based on field 1
    Field/List 4: New York, NY <-- Auto Populated based on field 1

    In the exit event of the first State field, using Javascript, something like this should work:
    State2.rawValue = this.rawValue;
    State3.rawValue = this.rawValue;
    State4.rawValue = this.rawValue;
    ...where "State2", "State3", etc. are references to the other dropdowns you want to populate with the same information from the first state field.
    Be sure to set the binding values in the BINDING tab of the dropdowns to the same in each dropdown,
    Brian

  • Dynamic dropdown based on user selection of another dropdown on the same page

    hi all, ok, I have a table which contains use data, a name,
    and a userID. for the example lets say "Simon Bullen" and my userID
    is "999".
    on a form I have, there is a dropdown box, which is dynamic
    from this table, and allows me to select Simon Bullen, however, I
    have a hidden field on the form, which when the user selects "simon
    bullen" the hidden field populates with the appropiate U number
    from the same table.... no i thought this would do it:
    <cfquery name="userNumber" datasource="userList">
    SELECT userNumber FROM dbo.Users WHERE Name =
    <cfqueryparam value="#form.Name#">
    </cfquery>
    and then my dynamic form field (hidden) would reference to
    this query....
    but it doens't work, could somebody please enlighten me? I'm
    hoping its something silly
    Thanks in advance

    You could make the value of the option the UserID and the
    option display the name.
    If that isn't what you need, I think you'll need some
    javascript to populate your hidden field based on what is chosen in
    the select.
    I think you can modify this:
    http://www.javascriptkit.com/javatutors/selectcontent2.shtml
    ...to populate your hidden field instead of a new select
    list.
    If there's a way to do that without JS I'm not aware of it.
    A third possibility: look up the UserID (based on the name
    chosen) after the form is submitted then do with it whatever you
    need to.

  • Populate 2nd combo box based on value selected in 1st combo box

    I am still using Acrobat 6 though I may be upgrading soon to Acrobat 8. I have a form with two combo boxes, the first "state" has values of MN and WI. Based on which value the user picks I would like to populate a "county" combo box with lists of counties that we deal with.
    Thanks,
    Gene

    One can set the option and export value using an arry:<br /><br />// document level script<br />// Master List of Lists <br />// Each entry in this object listeral is the name of a State <br />//Manually enter the State Names into the state field combo box <br />// The associated value is the item list, where each item is a name value pair, [<County> and [county code, zip code]] <br /><br />// state: ["county name", ["county code", "zip code"]]<br />var oStateNames = {MN: [["-", ["", ""] ], <br />                       ["St. Louis", ["MNStl", "55001"] ], <br />                       ["Carlton", ["MNSCrl", "55002"] ], <br />                       ["Pine", ["MNPin", "55003"] ],<br />                       ["Cook", ["MNCok", "55004"] ] <br />                       ], <br />                   WI: [["-", [" ", " "] ],<br />                        ["Douglas", ["WIDou", "55005"] ] ,<br />                        ["Bayfield", ["WIBay", "55006"] ],<br />                        ["Burnette", ["WIBur", "55007"] ],<br />                        ["Ashland", ["WIAsh", "55008"] ]<br />                       ]<br />                     }; <br /><br />//SetCountyEntries() on keystroke entry in state field <br />function SetCountyEntries() <br />{ <br />   if(event.willCommit) <br />   { <br />      // Get the new counties list from the Master List <br />      // Since the selection is being committed, <br />      // event.value contains the State name <br />      var lst = oStateNames[event.value]; <br />      // Clear the county list if there are no counties for the selected state <br />      this.getField("ee.address.county").clearItems();<br />      this.resetForm(["ee.address.code", "ee.address.zip"]);<br />      if( (lst != null) && (lst.length > 0) )<br />           this.getField("ee.address.county").setItems(lst); // set opiton and export value<br />   } <br />} <br />//  end document level script<br /><br />For the combo box "ee.address.county" one can create an array from the export value to populate the county code and zip code<br /><br />// custom keystroke for county combo box<br />if(event.willCommit & event.value != "") {<br />// split county and zip codes<br />var aCodes = this.getField(event.target.name).value.split(",");<br />this.getField("ee.address.code").value = aCodes[0];<br />this.getField("ee.address.zip").value = aCodes[1];<br />}<br />// end custom key stroke code

  • Populate a dropdown based on selected in another dropdown in a seperate table

    Good Day All;
    This may sound like a simple question to most, but… It has had me frustrated trying to figure out.
    I am trying to populate a dropdown based on what is selected in another dropdown.
    Let me explain what I have done so far.
    LifeCycle Designer 8.05.2
    When I had both dropdowns in the same table, I did not have a problem. The code I used is
    Table name is “Table1”
    if(directorate.rawValue == "1")
    division.clearItems();
    division.addItem("select")
    I was asked to move things around and now “division” is located in “Table2”
    I know I need to reference “Table1” but I am running into a Syntax error. I have tried the following code;
    if(Table1 Row1 directorate.rawValue == "1")
    division.clearItems();
    division.addItem("Faire un choix")
    if(Table1.Row1.directorate.rawValue == "1")
    division.clearItems();
    division.addItem("Faire un choix")
    Any help would be appreciated
    Chomp

    You're missing a semicolon at the end of the addItem line, and on the second code sample you've got no periods in the SOM reference (Table1 Row1 directorate). 
    The easiest way to get the path to another field is to ctrl-click on the field while you are in the script editor.

  • How to Add/Concatenate to a text field, values selected in a combo box

    I have a combo box form field that allows the user to select a value from a list and click on an Add button. The Add button should add/concatenate the vaue selected to a text field in order to create a list of values selected. I'm not sure how to do this using Javascript in Acrobat? I know I need to add the javascript to the Add button's Mouse Up action. Any help would be greatly appreciated. Thanks!

    Thanks so much - it works!
    >>> "Gilad D (try67)" <[email protected]> 9/25/2013 9:16 AM >>>
    Re: How to Add/Concatenate to a text field, values selected in a combo box created by Gilad D (try67) ( http://forums.adobe.com/people/try67 ) in JavaScript - View the full discussion ( http://forums.adobe.com/message/5712118#5712118 )
    Let's say the text field's name is "Text1", and the combo is called "Combo1". You can then use this code as the MouseUp script of the Add button:
    var f1 = this.getField("Text1");
    var f2 = this.getField("Combo1");
    if (f1.value=="") f1.value = f2.value;
    else f1.value = f1.value + ", " + f2.value;
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5712118#5712118
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5712118#5712118
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5712118#5712118. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in JavaScript by email ( mailto:[email protected].com ) or at Adobe Community ( http://forums.adobe.com/choose-container!input.jspa?contentType=1&containerType=14&contain er=3286 )
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • 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;

  • How to populate table of values based on selected value of dropdown list

    Hi
    I have an urgent requirement.
    Whenever I select a value in Dropdownlist, Based on the selected value I need to display serveral values in tabular form.
    I have created a dynamic LOV and created the actionListener
    I have created a table by dragging the ViewObject and i have set the partialTrigger attribute value to the LOV Id.
    Now My doubt is What should I return in the actionListener method
    Thanks

    Hi,
    So get the value what i tried is ,bind the list item of the select one choice ,
    and then i used the method something like this
    UISelectItems see=getSelectItems1();
    System.out.println("Selected Value"+ see.getValue());
    but it returns me something like this
    Selected Value[javax.faces.model.SelectItem@b20090, javax.faces.model.SelectItem@431753]
    Don't know what are those ,hoe can i get the display value.Please help.
    Thanks

  • How to make a value changed based upon values selected in dropdown menu

    Hi,
    I am making my first Dreamweaver website using Dreamweaver CS6 on a windows 8 PC.
    I am trying to make a website where the user selects different criteria; in this example an ipod's model, condition and size from three seperate dropdown selections (similar to www.itrado.co.uk) and then based upon these selections a value for their ipod is shown. However i cannot work out how to display a value which remains on the same page and changes based upon the values which have been selected from the dropdown boxes. I was planning on creating a database and then creating a simple code which retrieves the value from the database which corresponds to the three selected values, however i am not sure how to go about doing this.
    Any help would be greatly appreciated.
    Many Thanks,
    Henry

    You need scripts for this. Try this jQuery tutorial
    http://anthonygthomas.com/2010/03/14/display-form-fields-based-on-selection-using-jquery/
    Nancy O.

  • Populating values in dropdown based on values selected in second dropdown.

    Hi,
    I  have two listboxes on the screen. Based on value chosen in first dropdown, I want to populate the values to be selected in second dropdown. How can i achieve this? I would be glad if anyone can help me out with this requirement.
    Thanks,
    Ameet

    <font color=blue>Hi,
    <li> Place 2 input fields on screen.
    <li>Set Listbox property as it is shown in the below link.
         <a href="http://2.bp.blogspot.com/_O5f8iAlgdNQ/SmPSPnRa0tI/AAAAAAAAFCQ/wW_URP-ld6o/s1600-h/drop_down-770536.JPG" target="_new">link to dropdown setting</a>
    <li>Set function code to first dropdown box to trigger event when you select value from first dropdown box. So that second one is changed.
    <li>Declare variable like below in TOP include of the module pool program.
    <pre>DATA: g_drop_1 TYPE char10,
          g_drop_2 TYPE char10,
          ucomm    TYPE sy-ucomm.
    TYPE-POOLS vrm.
    DATA: name  TYPE vrm_id,
          list  TYPE vrm_values,
          value LIKE LINE OF list.</pre>
    <li> Use screen flow logic of the screen like below
    <pre>"PROCESS BEFORE OUTPUT.
    PROCESS BEFORE OUTPUT.
    field g_drop_1 MODULE drop_down_1.
    field g_drop_2 MODULE drop_down_2.
    "PROCESS AFTER INPUT.
    PROCESS AFTER INPUT.
    field g_drop_1.
    field g_drop_2.</pre>
    <li>Corresponding code for two drop down boxes.
    <pre>&----
    *&      Module  DROP_DOWN_1  OUTPUT
    MODULE drop_down_1 OUTPUT.
      CLEAR: list[],g_drop_2.
      name = 'G_DROP_1'.
      value-key  = '1'.
      value-text = 'value_1'.
      APPEND value TO list.
      CLEAR  value.
      value-key  = '2'.
      value-text = 'value_2'.
      APPEND value TO list.
      CLEAR  value.
      value-key  = '3'.
      value-text = 'value_3'.
      APPEND value TO list.
      CLEAR  value.
      value-key  = '4'.
      value-text = 'value_4'.
      APPEND value TO list.
      CLEAR  value.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id     = name
          values = list.
    ENDMODULE.                 " DROP_DOWN_1  OUTPUT
    *&      Module  DROP_DOWN_2  OUTPUT
    MODULE drop_down_2 OUTPUT.
      CLEAR list[].
      name = 'G_DROP_2'.
      CASE g_drop_1.
        WHEN 1 OR 2.
          value-key  = '1'.
          value-text = 'text1'.
          APPEND value TO list.
          CLEAR  value.
          value-key  = '2'.
          value-text = 'text2'.
          APPEND value TO list.
          CLEAR  value.
        WHEN 3 OR 4.
          value-key  = '3'.
          value-text = 'text3'.
          APPEND value TO list.
          CLEAR  value.
          value-key  = '4'.
          value-text = 'text4'.
          APPEND value TO list.
          CLEAR  value.
      ENDCASE.
      CALL FUNCTION 'VRM_SET_VALUES'
        EXPORTING
          id     = name
          values = list.
    ENDMODULE.                 " DROP_DOWN_2  OUTPUT</pre>
    Thanks
    Venkat.O</font>

  • Get values in dropdown field based on f4 help in another field

    Hi Experts,
    How to Get values in dropdown field based on another field which is F4 Help. If I select one value in f4 help field(ex: 1) I need to get values in dropdown field (ex:a, b, c),If I select another value in f4 help (ex:2) I need to populate different values (ex: d). Can any one please provide sample code that can help more.
    Thanks,
    Ashok.
    Moderation: Kindly search and find the solution, before you post.

    Dear Ashok,
    You can take help from this program in SAP named BCALV_EDIT_08.
    Thanks.
    With regards.

  • Infopath: How to load data in one field based on value selected in another field

    We have a drop down list field in the infopath form and we have some more fields that should change depending on the dropdown selection. 
    How can we achieve this please ?
    Thank you !

    Hi Prajk, sounds like you want to do cascading dropdowns. If so, see the link below. If you're just trying to enter information into a field (not a dropdown) based off the value of the dropdown, then set a rule so that if dropdown = "this," set
    the field's value to "this."
    http://blogs.msdn.com/b/bharatgupta/archive/2013/03/07/create-cascading-dropdown-in-browser-enabled-infopath-form-using-infopath-2010.aspx
    cameron rautmann

  • 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.

Maybe you are looking for