Dynamic Population of Select List

I am stuck in a very frustrating situation at present, I need to dynamically populate select lists based on user choices.
There are three drop down menus, only the first one is pre-populated with the other two populating upon user selection of the previous one. I am using JSP and JavaScript in conjunction. I need to make a function call to a back-end library which exists on a servlet to get the data for the 2nd and 3rd drop down menus, the parameter for the function being the user selected option in the 1st drop down menu.
I know I cannot use the JavaScript "onchange" event handler as that won't help me call the back-end library functions. One way that I think is feasible at the moment is to do page refreshing, i.e. include other JSP's in one main JSP and refresh them as soon the user makes a choice. The other way is to embed an applet in a JSP page and use the JComboBox from the Swing libraries to detect events and make HTTP connections to servlets. I believe there is a possibility of using Struts to do this as well. Can someone tell me which would be the best method to use and a general overview of how to go about using it? I am also open to other alternatives...
Thanx for any help in advance

this can be done in two ways.
one way:- try generating a hidden form fields with the values comma seperated.
like <input type='text' id= id1 name = select1 value = 'coma seperated list of second select values' >
on on change event you can get the list of values which you need to populate in the second select box. generate the options dynamically by splitting the coma seperated list into the second combo.
second way:- while loading the jsp store all the second select box coma seperated list in java script array. and based on the change event of first select box get the corresponding values from the array and split them and generate the options dynamically and populate the second select box.
I guess this way you can solve your problem.
write back to me on [email protected] if you need code snippets.
all the best
kiran J

Similar Messages

  • Dynamic Population of Select List    code

    I have two select box's in jsp.
    if i selct one item on chane method i have to
    pupulate them in second selectbox.can any body have
    code for that

    I am not sure if you are using database for retrieval but in such a scenario you can do this:
    in case the option value/name for your first select box are unique, you can store this value in a particular variable and write another query to retrieve the value which you require in the select box in an Array by using the variable and finaly iterating through the array to have the select box populated.
    Hope you understand this and it helps you out.

  • DYNAMIC LOV FOR SELECT LIST

    hi to all,
    i've a question regarding lov query based select list:
    For a certain user i need that the lov display a list
    if app_user = BACK_OFFICE I NEED THAT ther query on wich is populated the
    select list is qry 1.
    if app_user is another (consultant) i need query 2 for populating the select list
    1) select name|| ' ' || fname D, id K from partner
    2) select name|| ' ' || fname D, id K from partner WHERE UNAME=(:APP_USER)
    Any solutions would be greatly appreciated.
    Another solution would be to have 2 different apps (one for back-office, one for external consultant), but there i should always duplicate all changes to the second one, loosing a lot of time.
    Now thinking as well to use hidden fields.
    If not clear enough please ask me.
    Thanx a lot.
    Message was edited by:
    Marcello Nocito

    I think one solution wold be to create two different named querys, one containing query 1 and the second query 2. Than u must create an Application Item(like a session variable) in wich u will store you condition. If you want to use the app_user variable u allready have it so you don't need to create it any more. On your page where u want to display the different select list u create two items, one with the query 1 as source and a second item(select list) having the source query 2. Then you must add a condition display on both of them like. Item one is displayed when Value of Item in expression 1 equals expression 2. And you pust :APP_USER in expression 1 and BACK_OFFICE in expression 2. And for the other item, that contains query 2, you put the opposite condition Value of item in expression 1 is not equal to expression 2, and expression 1 is :APP_USER and in expression 2 is BACK_OFFICE.
    Hope this helps.
    Florin

  • Populating a SELECT list from an Oracle Table

    Hello,
    I would like to populate a second SELECT list on
    a web page based on the selected value in the first
    SELECT list. I would like to take the value
    that the user selects in the first SELECT list and
    use it in a WHERE clause to bring back distinct
    values to display in the second SELECT list.
    I would like to do this all on a single page. As
    soon as the user selects a value in the first SELECT
    list, then the correct values retrieved from the
    database would appear in the second select list.
    Is this possible? Do you have sample code or ideas??
    I can write JavaScript to get the selected value, but
    I cannot get to Oracle data from the JavaScript environment.
    I can write PL/SQL or Java procedure to access
    Oracle data, but I cannot make the complete connection.
    Help, please.
    thanks
    paul

    Unless you can get every combination back in the first SQL statement, you'd have to do something along the lines of
    - Have the JavaScript submit the page as soon as the first pull-down is selected
    - Have the response be a page identical to the first page, but with the second pull-down populated.
    The other option would be to have a Java applet that can make the second query and return results. Since applets can't connect to the database by default, you'd have to have an app server that would do the actual query.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com/askDDBC

  • Dynamic Actions in Select List of Tabular Form

    I have a tabular form in my application and one of the column A is Select List with lot of values. My requirement is, there is another column B in the same tabular column like Display text, which should appear when a user select A, B or C in the select list column A. Is it possible, how can I implement it?
    I tried it through Dynamic Actions ->DOM Objects, but I am not sure what is the name of the Select List column value that needs to be specified, it is jst f06 or f06_???. Can someone tell me the exact steps that needs to be followed.

    My mistake, Javascript (and DOM attributes/methods) are case-sensitive. The attribute in question is readOnly, not readonly
    I fixed it on my example page at http://htmldb.oracle.com/pls/otn/f?p=24317:255
    <script type="text/javascript">
    function ro_Item(nd,a){
        var lEl = html_GetElement(nd);
        if (lEl && lEl != false){
           if(a){
          lEl.readOnly = true;
          lEl.style.background = '#cccccc';
        }else{
          lEl.readOnly = false;
          lEl.style.background = '#ffffff';
         return true;
    function foo(pThis)
    var lTD=pThis.parentNode;
    var nextinput=lTD.nextSibling.getElementsByTagName('input')[0];
    var nextnextinput=lTD.nextSibling.nextSibling.getElementsByTagName('input')[0];
    if (pThis.value=="CLERK") {
      ro_Item(nextinput,true);
      ro_Item(nextnextinput,true);
    else {
      ro_Item(nextinput,false);
      ro_Item(nextnextinput,false);
    </script>

  • Fetch - populating a selection list

    Is it possible to create a fetch mapping that populates a selection  list with different values for the display value and the key  value?  You can do this in Service Designer for predefined SQL  queries.
    I need to perform a dynamic query that populates a  selection list with display values users will understand, but whose  underlying values are really unique identifiers.
    In the end I'm  trying to build a hierarchical series of selections where the value of  the most recent selection becomes a parameter to the next query.
    I  could probably perform the fetch and then manually iterate over the  result set in javascript, adding the values to the selection list, but  I'm wondering if there is an easier way.
    I'd like to be able to do something like the following, but I don't think its possible.
    &lt;map name="M1"&gt;
    &lt;entry Field="BETA_ID_NEW.DepartmentBranch.Name" Column="DisplayName"/&gt;
    &lt;entry Field="BETA_ID_NEW.DepartmentBranch.Value" Column="Value"/&gt;
    &lt;/map&gt;

    Unfortunately, you are correct, there is no way to do this except by hitting it over the head. But your proposed solution is interesting -- if it worked at all, I suspect fetch would populate two drop-down/select lists, rather than 1. (I've tried this, but actually doing two fetches -- very wasteful.) But then, you wouldn't have to iterate through the entire list, just set the selected index for the second (value) list, not writeable by the user (hidden?), to the index just selected by the user for the f

  • Dynamically changing the select list in an LOV based on the login user

    We have a field in a form which is a combobox.The form is to be linked to different profiles of users.Based on the logged in user we would like to restrict the select list in the LOV.ie user1 should see a LOV which is different from that seen by user2.Is this possible.If so how can this be done?Kindly reply.
    Thanks & Regds,
    Jayanthi

    Thanks for ur reply.But my problem is that i have a table having details of some products which includes spareparts also(Name,id,price etc).In my form i have the combobox field which should have a list of these products which the user can select.Now depending on the user's profile he should see only his related products(One profile of users should view only the products but not the spares while the other should view only spares.)The details of both the products and spares are in the same table.we have a criteria to differentiate between the products and the spares.The LOV should display at run time, either products or spares depending on his profile as he logs in. Hope u understood my problem.
    Regds,
    Jayanthi
    Hello Jayanthi,
    I had a similar situation in my last project.
    While you can solve this by modifying your query, this will always come around as may be later some other criteria to restrict based on User/His Role/Something else. Hence I fixed it at design level itself. Though I can't give my situation I can tell you the solution applying my logic.
    Altering your Product Table and adding one more database Column say Product_Category and updating the table with Product Category =1 for Products and 2 for Spares. You can extend this further for other types.
    Create a new Table say User_Groups that will have
    Group_id
    Group_Name
    User_Id columns and will contain all the User ids inserted groupwise.
    Create one last Table Group_Product_Map
    That will have
    Group_id
    Category_id
    This will store each Group_Id followed by Category_id of Products to which these group members will have access to.
    Now write a database function getCategory( p_User) which will query User_Groups table to get Group_Id
    and further query Group_Product_Map Table based on group_id to get Category_Id.
    This function will return category_id.
    Huh!
    So your LOV will have a query as select *(or whatever) from Product where category_id = getCategory(portal30.wwctx_api.get_user)
    Hope this helps
    Madhav

  • Dynamic Parent/Child Select List - Parent may have only a single entry

    Hello,
    I have a parent/child select list implemented using APEX only, ie no AJAX.
    The child list always has multiple entries, but the parent may only have a single entry, depending on who is running the application. When the parent has just one entry it can't submit, so the child list remains empty. Also when the parent has multiple entries, the user must select another entry from the parent list to cascade the child list.
    I have put a button to fire the branching to same page submit, but this is a little clunky. Is there a way of cascading the child list when the page opens? Preferably without ajax, but if has to be then ok
    I've looked for an answer to this but all threads I have followed seem to assume parent to have multiple entries, and that child list requires parent selection, but this not so in my application.
    Thanks, Jock

    Anyone?
    Even an acknowledgment that this should be obvious to me, or that it is not currently possible would be of assistance.
    Thanks,
    Jock

  • Dynamic population of second list box based on the selection of first list

    Hai Friends,
    I have the code like this.
    Here my issue is: when the user accesses this page he will get the topic and related categories in the drop down boxes. but when the user changes the topic it needs to populate the categories from the database and kept the topic same for the respective categories. so how can i do this?
    <form name="questionForm" method="post" action="listQuestions.lgs">
    <table bgcolor="F8D8D8" cellspacing="2" cellpadding="2" align="center"
         style="margin-top: 100px">
         <tr>
              <td>Topics:</td>
              <td><select name="topic">
                   <c:forEach items="${model.topics}" var="topic">
                        <option value="<c:out value="${topic.topicId}" />"><c:out
                             value="${topic.topicName}" /></option>
                   </c:forEach>
              </select></td>
              <td>Categories:</td>
              <td><select name="category">
                   <c:forEach items="${model.categories}" var="category">
                        <option value="<c:out value="${category.categoryId}" />"><c:out
                             value="${category.categoryName}" /></option>
                   </c:forEach>
              </select></td>
         <tr>
              <td><a
                   href="addQuestion.lgs?categoryId=2<c:out value="${category.categoryId}"/>">Add
              New Question</a></td>
              <td></td>
              <td></td>
              <td></td>
         </tr>
         <tr>
              <td>Questions under this Category:</td>
              <td><c:if test="${model.questions} == null">
                   <c:out value="no questions found" />
                   <br>
              </c:if> <c:if test="${model.questions} != null">
                   <c:forEach items="${model.questions}" var="question">
                        <table>
                             <tr>
                                  <c:out value="${question.questionDesc}" />
                             </tr>
                        </table>
                   </c:forEach>
              </c:if></td>
         </tr>
         <tr>
              <td colspan="2"><input type="submit" /></td>
         </tr>
    </table>
    </form>
    regards,
    phani.

    Hi Rahul,
    I followed the link what you have mentioned and i need clarification in regarding this....
    function getResponseAction(){
    // Verifying State & Status
    if(verifyReadyState(xmlhttp) == true){
    // Building a DOM parser from Response Object
    var response = xmlhttp.responseXML.documentElement
    // Deleting all the Present Elements in the Drop-Down Box
    drRemove()
    // Checking for the Root Node Tag
    var x = response.getElementsByTagName("option")
    var val;
    var tex;
    var optn;
    for(var i = 0;i < x.length; i++){
    optn = document.createElement("OPTION")
    var er
    // Checking for the tag which holds the value of the Drop-Down combo element
    val = x.getElementsByTagName("val")
    try{
    // Assigning the value to a Drop-Down Set Element
    optn.value = val[0].firstChild.data
    } catch(er){
    // Checking for the tag which holds the Text of the Drop-Down combo element
    tex = x[i].getElementsByTagName("text")
    try{
    // Assigning the Text to a Drop-Down Set Element
    optn.text = tex[0].firstChild.data
    } catch(er){
    // Adding the Set Element to the Drop-Down
    document.questionForm.category.options.add(optn)
    but in my springframe work i have the controller like this where i am putting category object in the context and i am retrieving this in my listQuestions.jsp like this
    <tr>
              <td>Topics:</td>
              <td><select name="topic" onchange="populateCombo(this.value)">
                   <c:forEach items="${model.topics}" var="topic">
                        <option value="<c:out value="${topic.topicId}" />"><c:out
                             value="${topic.topicName}" /></option>
                   </c:forEach>
              </select></td>
              <td>Categories:</td>
              <td><select name="category">
                   <c:forEach items="${model.categories}" var="category">
                        <option value="<c:out value="${category.categoryId}" />"><c:out
                             value="${category.categoryName}" /></option>
                   </c:forEach>
              </select></td>
         <tr>
    package com.lgsglobal.lgsexam.spring.controllers;
    import java.util.HashMap;
    import java.util.List;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.springframework.web.servlet.ModelAndView;
    import org.springframework.web.servlet.mvc.Controller;
    import com.lgsglobal.lgsexam.dao.CategoryDAO;
    import com.lgsglobal.lgsexam.dao.QuestionDAO;
    import com.lgsglobal.lgsexam.dao.TopicDAO;
    import com.lgsglobal.lgsexam.hibernate.pojos.Category;
    import com.lgsglobal.lgsexam.hibernate.pojos.Topic;
    public class ListQuestionsController implements Controller {
         private TopicDAO topicDAO = null;
         public void setTopicDAO(TopicDAO topicDAO) {
              this.topicDAO = topicDAO;
         public TopicDAO getTopicDAO() {
              return this.topicDAO;
         private QuestionDAO questionDAO = null;
         public void setQuestionDAO(QuestionDAO questionDAO) {
              this.questionDAO = questionDAO;
         public QuestionDAO getQuestionDAO() {
              return this.questionDAO;
         private CategoryDAO categoryDAO = null;
         public void setCategoryDAO(CategoryDAO categoryDAO) {
              this.categoryDAO = categoryDAO;
         public CategoryDAO getCategoryDAO() {
              return this.categoryDAO;
         public ModelAndView handleRequest(HttpServletRequest request,
                   HttpServletResponse response) throws Exception {
              HashMap mymodel = new HashMap();
              List topics = topicDAO.getTopics();
              mymodel.put("topics", topics);
              if (request.getParameter("topic") != null) {
                   System.out.println("in topics condition to retrieve questions");
                   int topicId = Integer.parseInt(request.getParameter("topic"));
                   Topic topic = topicDAO.getTopic(topicId);
                   List categories = categoryDAO.getCategories(topic);
                   mymodel.put("categories", categories);
                   System.out.println("exiting topics condition to retrieve questions");
              if (request.getParameter("category")!= null) {
                   System.out.println("in category condition to retrieve questions");
                   int categoryId = Integer.parseInt(request.getParameter("category"));
                   Category category = categoryDAO.getCategory(categoryId);
                   List questions = questionDAO.getQuestions(category);
                   mymodel.put("questions", questions);
              return new ModelAndView("listQuestions", "model", mymodel);
    so here my issue is like how i can populate categories in the category(dependent combo). so please let me know the solution.
    awaiting for reply. for any furthere info please let me know....
    regards,
    Phani.K

  • Dynamically Populating Drop Down Lists

    Hi,
    I am trying to dynamically populate a drop down list on a form based on a selection in another drop down list. I have read the help file "To dynamically populate a second field after populating the first" which goes through an example, however I cannot get this example to work for me.
    I know that the best way to do it is to create an xml file and connect the form to this file. I am new to programming in xml but have had some experience in other forms. The code that I have (from the help page) looks like this;
    <?xml version="1.0" encoding="UTF-8"?>
    <MyData>
       <country/>
       <countries>
          <item uiname="United States" token="US"/>
          <item uiname="Vietnam" token="SRV"/>
       </countries>
       <state/>
       <US>
          <item>California</item>
          <item>New York</item>
          <item>Texas</item>
       </US>
       <SRV>
          <item>An Giang</item>
          <item>Bac Giang</item>
          <item>Bac Kan</item>
       </SRV>
    </MyData>
    I have then followed the instructions on the page, and am unable to populate either field on my form. Perhaps there is something wrong with my code? Or any other suggestions would be greatly appreciated! 
    Thanks

    Hi Paul,
    I have another question,
    I would now like to populate a third drop down menu based on the selection in the second one, however my code is going wrong somewhere as now when I put in the first 2 drop down lists, nothing appears in the second one. ie, the first drop down list I link to countries, and the second to state, as I did with the previous file, but now, when I preview it, I can choose a country, but nothing comes up in state. When I set the first drop down box to countries, I have to specify that I want it to show the uiname, but I can't do that with the second one when I select state using the XML file below, nothing is shown. Where am I going wrong?
    <MyData>
       <Country/>
       <countries>
          <item uiname="United States" token="US"/>
          <item uiname="Vietnam" token="SRV"/>
       </countries>  
       <state/>
       <US>
          <item uiname="California" token="CA"/>     
          <item uiname="New York" token="NY"/>   
          <item uiname="Texas" token="TEX"/>
       </US>
       <SRV>
          <item uiname="An Giang" token="AG"/>
          <item uiname="Ban Giang" token="BG"/>
          <item uiname="Bac Kan" token="BK"/>
       </SRV>
       <time/>
       <CA>
          <item>6</item>
          <item>7</item>
       </CA>
       <NY>
          <item>5</item>
          <item>4</item>
       </NY>
       <TEX>
          <item>3</item>
          <item>8</item>
       </TEX>
       <AG>
          <item>2</item>
       </AG>
       <BG>
          <item>1</item>
       </BG>
       <BK>
          <item>9</item>
       </BK>
    </MyData>
    Thank you for your help!

  • Dynamically populating a dropdown list in a pdf form from a datasource

    Is there a way to populate a dropdown list in a pdf form from a datasource, specifically from an Access database table or query, using LiveCycle Designer. I am easily able to do this using cfselect in Coldfusion, however, cannot seem to figure it out for pdf forms. I am aware of the Show Dynamic Properties option enabled in LiveCycle Designer, and then binding to a datasource. However, this seems limited as I am only able to select single columns from Access (currently using an Access database) tables, and a unable to select from queries like I do using cfselect in Coldfusion forms. Is this something that must be done with Java scripting? If so, is there any other way? I know nothing about scripting. Thanks

    Derrick,
    There is a sample posted at
    http://www.adobe.com/devnet/livecycle/articles/lc_designer_db_lookup_tip.pdf
    It was created for Designer 7.0 but it should function the same in later versions of Designer.
    Steve

  • Dynamic Select List based on TextField data

    Hi,
    I like to dynamically display the select list based on the value in the textfield, the data in the textfield is of character type.
    Thanks

    Hello,
    Well as you now know HTML based select lists don't work like that, that widget is called a combo box and there will be built in combo boxes in APEX 3.0, it's a fairly complex dhtml widget.
    What you might want to do is provide a text item next to your select box and an Add New Value Option in your select list.
    Carl

  • Select List Population

    I have two select lists.The first one holds the column names of a table and the second one should populate all the distinct values of the column selected in the first list.
    In the second select list I have written a query like
    SELECT DISTINCT V('P4_TOP_SEARCH') p,V('P4_TOP_SEARCH') r FROM INTERVIEW_DETAILS
    where 'P4_TOP_SEARCH' is the session state value and is a column of a table.
    I am not getting values but the session state value is populated in select list
    Is there any way to do it.

    Is there anyone to help me out.

  • Set Radio Group Default Value Based on a Select List Change Event

    Apex 4.2
    I have a radio group that is source is below. It returns 3 radio group item All,Miv,Courier
    SELECT type d, code r FROM vw_lov_depot
      WHERE svc_name = :P320_DEPOT
      ORDER BY 1
    The radio group is only populated when :P320_DEPOT gets a value, this is a select list.
    I am trying to set the radio group to  default to this value Miv it would use the statement
    SELECT type d, code r FROM vw_lov_depot
      WHERE svc_name = :P320_DEPOT
      and type ='Miv'
      ORDER BY 1
    I have tried creating a dynamic action on Select list change to populate the default value of the radio group...no joy I also tried a computation. how can I set this default value on when list changed.
    Thanks
    I have got the default Radio Group Selection working by doing a computation before region on the radio group and calling its select statement and setting the value. But the problem is now I cannot change the radtio group as I do it fire the before region trigger and sets it back to the default value....any help?

    Hi,
    Could you please create example to apex.oracle.com?
    Regards,
    Jari

  • How to implement casading select lists  in ADF?

    I have three select list, when select list 1 is changed appropriate value needs to populated in select list 2 and similarly when select list 2 changed, select list 3 should be populated. I'm a newbie to ADF, any ideas are appreciated. Also, really appreciate if someone can point some sample application which illustrates some of these features.
    Regards,
    Surya

    This will help http://tinyurl.com/26b735s

Maybe you are looking for