Changing value in drop-down based on selected value in another drop-down

Hi,
I have two drop-downs - changing value in Combo1, should cause the form to be submitted and values to be populated in Combo 2.
Approaches i tried - 1) I am using an ActionListener. I am having a valueChange method which accepts an action event. However this appraoch is not working for me. 2) I was wondering if I could use Javacsript to catch the OnChange event , the javascript function would call an appropirate method in my ActionListener. I know in Struts its straightforward, but how do i achive the same here in JSF.
Any tips would be helpful.
Thanks
PS: I already came across some threads in the forum, but could not get an answer. Also, I have a retsriction in terms of using Action LIsteners itself.

Try using ValueChangeListener instead of ActionListener.
Here's a working example of a ValueChangeListener. You can customize it and use it for your application.
The JSP will look like this:
     <h:selectOneMenu value="#{globalsBean.selectedFirst}"
          valueChangeListener="#{globalsBean.changeList}" onchange="submit()">
          <f:selectItems value="#{globalsBean.first}" />
     </h:selectOneMenu>
     <h:selectOneMenu value="#{globalsBean.selectedSecond}">
          <f:selectItems value="#{globalsBean.second}" />
     </h:selectOneMenu>The globalsBean will look like this:
public class GlobalsBean extends Bean {
     ArrayList first;
     ArrayList second;
     String selectedFirst;
     String selectedSecond;
     public GlobalsBean() {
          first = new ArrayList();
          second = new ArrayList();
          first.add(new SelectItem("1", "1"));
          first.add(new SelectItem("2", "2"));
          selectedFirst = "1";
          selectedSecond = "";
          second.add(new SelectItem("White", "White Cows"));
          second.add(new SelectItem("Brown", "Brown Cows"));
          second.add(new SelectItem("Green", "Green Cows?!?"));
     public ArrayList getFirst() {
          return first;
     public ArrayList getSecond() {
          return second;
     public String getSelectedFirst() {
          return selectedFirst;
     public void setSelectedFirst(String selected) {
           selectedFirst = selected;
     public String getSelectedSecond() {
          return selectedSecond;
     public void setSelectedSecond(String selected) {
           selectedSecond = selected;
     public void changeList(ValueChangeEvent event) throws AbortProcessingException{
          second = new ArrayList();
          String newValue = (String)event.getNewValue();
          setSelectedFirst(newValue);
          if (newValue.equals("1")) {
               second.add(new SelectItem("White", "White Cows"));
               second.add(new SelectItem("Brown", "Brown Cows"));
               second.add(new SelectItem("Green", "Green Cows?!?"));
          } else if (newValue.equals("2")) {
               second.add(new SelectItem("White/Black", "White Cows with Black spots"));
               second.add(new SelectItem("Black", "Black Cows"));
          setSelectedSecond("");
}Let me know how it works out for you.
CowKing

Similar Messages

  • Populate elements in a drop based on selection made in another drop down

    i need to populate elements in a drop based on selection made in another drop down list. have created list models for populating data from R3. I am using PDK for java development.

    hi,
    to populate the second dropdown from the selection of the first u need to the submit the form on the selection of data from dropdown and based on the selection populate the second dropdown.
    If using jspDynpage u can submit the form on the  ''onChange" event of first drop down.
    If you can let us know what type of application is this i think we can help you in more better way.
    Thanks
    Ritushree Saha

  • The drop down list values want to vary based on the contents of another drop down field

    hi,
    hi in search page i have two drop down list. i have two tables and one mapping tables. service line and subservice line are tables and i have one mapping table. using rapid application i create one component using mapping table. now in search page i have two drop list. one is servline and another is sub serviceline. in service line i have values like 1,2 k  for subservice 3,4.5,6 for one service line ex. for 1 i have two subservice 3,4 and for 2 i have 5,6. now my requirment in if i choose service line 1 in first drop down list, automatically in second drop down list want to contain values 3, 4. before both the drop down list have values.if i chose one value the correponding mapping value want to come in drop down list in same context node.

    Hi,
    This requirement involves defining p-getter for the service type, and the v-getter of you sub type.
    Since this involves to populate the values of subtype attribute depending on value of service type, u need a round trip.
    This is done in the p-getter of the 1st attribute(service type in your case).
    In the v-getter of the 2nd attribute, 1st fetch the current value of attribute 1, then filter the value in the dropdown table according to ur logic.
    Ref :Drop down values in table view
    Regrads
    Anish

  • Passing DB values to the textbox based on Select Value item

    Hi,
    I am very much new to the Oracle APEX. In my project, I have a requirement wherein I have to pass the different values to the corresponding textboxes on a different page based on the value I select from the "Select Value" item.
    I have tried using calling On-Demand Processes, but couldn't get the desired result.
    Please suggest!

    Hi 796444 ,
    Welcome to the forum. It will be good if you familiarize yourself with the forum ettiquittes. Also, when posting always state the following:
    a. Apex version
    b. DB version
    c. Web server ; EPG, apexlistener, etc
    d. Provide adequate details for others to understand your problem / what you are trying to achieve.
    e. Any code snippets you post should be enclosed in a pair of tags
    If your current problem is that the you are *calling* Page 2 from Page 1, and while doing so you want the value of P1_ITEM1 to be passed and set in p2_ITEM1 then
    a. Edit the branch
    b. In Action in Set these items write P2_ITEM1
    c. In With these values write &P1_ITEM1. (do not miss the dot at the end)
    It looks good if you use a better handle than 796444 :-)
    Regards,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to get value in Second Drop Down based on selection made in first dropd

    Hi All,
    I have a table with first two columns as dropdown.
    The values in first drop down are fixed. However the value in second dropdown should be populated based on selection made in first .
    e.g
    First Column had different departments say IT, SALES, HR.
    Based on department selected I have to populate employee of that department.
    For first dropdown I have taken Drop down by index.
    What should I select for second drop down and achieve desired functionality? Please guide.
    Regards,
    Madhvika

    Hi
    Use drop down by key for fixed values IT, SALES, HR. create on_select action for that drop down.
    in on_select method code like this..
      DATA lo_nd_segment1 TYPE REF TO if_wd_context_node.
      DATA lo_el_segment1 TYPE REF TO if_wd_context_element.
      DATA ls_segment1 TYPE wd_this->Element_segment1.
      data lt_segment1 type wd_this->elements_segment1.
      DATA lv_segment TYPE wd_this->Element_segment1-segment.
      data lr_column type ref to cl_wd_table_column.
    navigate from <CONTEXT> to <SEGMENT1> via lead selection
      lo_nd_segment1 = wd_context->get_child_node( name = wd_this->wdctx_segment1 ).
    get element via lead selection
      lo_el_segment1 = lo_nd_segment1->get_element( ).
      lo_el_segment1 = WDEVENT->GET_CONTEXT_ELEMENT( 'CONTEXT_ELEMENT' ).
    get all declared attributes
      lo_el_segment1->get_static_attributes(
        IMPORTING
          static_attributes = ls_segment1 ).
    now ls_segment1 contains your first drop down selection value.
      DATA : lv_dropdown type string .
      lv_dropdown =  ls_segment1-segment.
      if lv_dropdown = 'IT'.
    // here fill your second drop down based on IT value.
    endif.
    Hope it solves.
    Cheers,
    Kris.

  • Clearing Value in one Prompt based on selection in another

    Hello,
    I have 2 prompts in my BEx query designer for same characterstics ( one is single value, characterstic variable and another one is Hierarchy node variable ). During the query execution,  If user selects a value in first prompt and goes to the other prompt and selects a value, i need to clear the selected value in the first prompt. And vice versa as well.....
    Please suggest.

    Jagan,
    Let me explain my isue in detail...
    I have created 2 variables for the same characterstics and both of them are ready for input. One variable is of characterstic type and other is Hierarchy node type.
    Now, when user executes the query he sees two prompts. Lets say user selects a value for one prompt and then goes to second prompt and selects another value for the second prompt, then i need to clear the values that was selected by him for the first prompt. And vice versa....

  • Selective drill down based on particular values

    Hi,
    I would like to know if it is possible to enable drill down only to certain values in a column and the other values in that column should not have the option for a drilldown(hyperlink should not be enabled).
    PS: dimensions are established correctly in the RPD. All other conditions are satisfied.
    Col1
    val1<hyperlink enabled>
    val2<no hyperlink>
    val3<no hyperlink>
    val4<hyperlink enabled>
    Now val1 and val4 should have drilling option. Is this possible in 10g/11g ???
    Thanks for your time and help....
    Kiran

    Hi,
    In obiee11g it's possible u r use Action Link method with conditional option. refer my below screen short.
    http://imageshack.us/photo/my-images/687/actionlink.jpg/
    i have implemented this method and it's working fine.
    Refer: action link method:
    http://siebel-essentials.blogspot.com/2010/09/11-obiee-11g-tips-7-action-links.html
    http://www.rittmanmead.com/2010/07/obiee-11gr1-action-framework-and-conditions/
    THanks
    Deva
    Edited by: Devarasu on Dec 9, 2011 1:17 PM

  • Selecting an LOV item to return values in antother item based on selection

    I am having some difficulty hard coding a page item P3_INVOICE_STATUS value to return/ display values depending on a multiple select list on another item P3_EXCEPTION_REASON'. Example when i select from a drop down list on P3_EXCEPTION_REASON' = is a drop down LOVs, I’d like to select from = YES/ NO/ NA, and would like that to return/ display COMPLETE/ PENDING / REVIEW respectively, depending on what is selected.
    Can anyone please help
    I am still a novist in APEX .

    hi,
    to create application level process:
    1. go to shared component
    2. in logic section there is "application processes", in which you can create process
    3. For item you can click "application item".
    regards,
    Kartik

  • 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

  • Select list coloured based on selected value

    Hello,
    Could anyone please tell me if it is possible to display a LOV with a background colour based on the selected value ?
    In fact , I have a report with many select lists whose value can be Y,N,N/A and I would like that the corresponding LOVs have the background colour set according to the value .
    Thanks in advance,
    Andreea
    Edited by: user12064977 on 20-Oct-2009 02:15

    Andreea,
    Lets assume your select list item name is P1_SL and return values as follows
    Display -  Return
    N/A     -  NA
    YES     -   Y
    NO      -   NEdit you page and put JS code similar to following in footer section
    <script>
    slval = $v("P1_SL");
    sl = $x("P1_SL");
    if(slval=="Y")
    sl.style.backgroundColor="#FFCC80";
    else if (slval=="N")
    sl.style.backgroundColor="#CCAA80";
    else
    sl.style.backgroundColor="#CCCC80";
    </script>So background color will be set on page load.
    Now edit your page and put JS code similar to following in HTML Header section
    <script>
    function setColor(this1)
    slval = this1.value;
    if(slval=="Y")
    this1.style.backgroundColor="#FFCC80";
    else if (slval=="N")
    this1.style.backgroundColor="#FFAA80";
    else
    this1.style.backgroundColor="#CCCC80";
    </script>Edit your select list item and set following for 'HTML Form Element Attributes'
    onChange="javascript:setColor(this);"So the select list color will be set accordingly 'onChange'.
    Cheers,
    Hari

  • Change template type of region based on item value

    Hi All,
    Is it possible to change a template type of a region based on value of page item?
    For example, if I have a template type for Region A as Hide/Show region and template type for Region B as Hide/Show as well.
    I want the template type of Region B to be changed to a custom template type based on the value of an item in Region A.
    Is this possible?
    Appreciate your inputs.
    Thanks!

    spriya wrote:
    Hi All,
    Is it possible to change a template type of a region based on value of page item?
    For example, if I have a template type for Region A as Hide/Show region and template type for Region B as Hide/Show as well.
    I want the template type of Region B to be changed to a custom template type based on the value of an item in Region A.
    Is this possible?No. You'd either need to have 2 instances of Region B based on different templates, and render one of them conditionally according to the Region A value; or develop a single template with a structure flexible enough to be used in both cases, and change its appearance/behaviour by for example, swapping classes in a Dynamic Action.

  • Autosuggest based on Select Value

    I'm in the process of reworking a pre-existing form and
    related queries that
    allows a person to search for my agency's services based on
    City, County or
    ZIP Code.
    We have two fields: locationtofind (text field) and
    locationtype (select
    containing the above values, with City being the default)
    What I'd like to do is populate the autosuggest with values
    based on the
    value of the currently selected locationtype. How do I pass
    or bind the
    currentvalue of locationtype to the autosuggest call to a
    CFC?
    Texas has a huge number of place names in addition to its 254
    counties, so a
    dynamic search using a cfc as you type query is a must.
    Any examples would be quite helpful.
    Thanks in advance,
    Michael Brown
    Texas Department of Aging and Disability Services

    I'm in the process of reworking a pre-existing form and
    related queries that
    allows a person to search for my agency's services based on
    City, County or
    ZIP Code.
    We have two fields: locationtofind (text field) and
    locationtype (select
    containing the above values, with City being the default)
    What I'd like to do is populate the autosuggest with values
    based on the
    value of the currently selected locationtype. How do I pass
    or bind the
    currentvalue of locationtype to the autosuggest call to a
    CFC?
    Texas has a huge number of place names in addition to its 254
    counties, so a
    dynamic search using a cfc as you type query is a must.
    Any examples would be quite helpful.
    Thanks in advance,
    Michael Brown
    Texas Department of Aging and Disability Services

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

  • Update Drop Down based on selection in Option group

    Good afternoon all-
    I've got an option box ('PanelStatus') with two options: "Panel" (value of 1) and "Non-Panel" (value of 2).
    On the form where this is located, I have a drop down box filled with names.  These people on this table are either Panel or Non-Panel.  So, my idea is that the drop down with names will be refreshed when the radio buttons in PanelStatus are clicked.
    I've got a query that will return the right results, based on what's selected in the Option Group.  However, when I set the Option Group after update event to refresh the dropdown box, Access is telling me "Object doesn't support this property
    or method".
    Any ideas/help are welcome!
    EDIT: I'm thinking it may be because the drop down is unbound...?  Does that explain why this is not working?  If so, any ideas how to do this with the drop down remaining unbound?

    The After Update event of an option group works whether the option group is bound or unbound.
    You should use the Requery method of the combo box.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Showing and hiding dropdowns on product page, based on selected values

    Hello.
    I would like my product page to show different subsequent dropdowns based on individual dropdown values.
    I've managed to achieve this via JavaScript, but I do not like how it works.
    As far as I can tell, there is no proper identifier for each individual dropdown to determine which one it is, so all I can do at the moment is to rely on their order in the DOM, which is bad and makes it difficult for me to create a solution that would work for all products.
    For instance, if the following is a single attribute:
    <div class="catProductAttributeGroup" style="display: none;"><div class="catProdAttributeTitle">Metallic Foiling</div><div class="catProdAttributeItem"><select><option value="">-- Please select --</option><option value="6051720">Not required </option><option value="6051721">Foil ONE side + £45</option><option value="6051722">Foiling BOTH sides + £75</option></select></div></div>
    I would like the outer-most div to have some sort of html attribute that holds the product attribute id. Something like, data-attribute-id="XXXXXXX". Is that possible?
    Here's what I have up to this point:
    I use {tag_attributes_json}, {tag_product_json} and {tag_currency} to get these values into javascript on page load, so I can use them later.
    Then, I hook to change events of the drodpowns I have and then toggle their visibility based on which ones are selected. I rely on the jequery ':eq(n)' selector to achieve this, which I do not like. Is there an option for the {tag_attributes} helper which would make it add some extra information (such as attribute ID on the dropdown) on the generated HTML?
    All of this works initially, but If I then 'Add to cart', the product element get's ajax-reloaded and the events are suddenly unhooked, so it doesn't work anymore. For that one, there are two options:
    1. I could hook to an event that triggers once the product has been added to cart and the page is ready again. Is there such an event?
    2. I could implement my own add to cart using bcInternals.shop.addToCart. I tried doing this, but I have two problems with it.
    a. addToCart seems to add my selection twice, for some reason. Any ideas what I might be doing wrong?
    b. the cart info in  the top right corner doesn't refresh. it seems it tries to refresh, but there's some sort of access error in the script. This part is not yet fully added to the page, but there's a function that would do the adding to cart at the bottom of the bigger script block. Am I using the built in addToCart function incorrectly?
    This is the page I have the partially implemented functionality added on:
    Matt Laminated Business Cards
    The scripts are currently embedded inside the HTML. Once I have it properly implemented, I'd like to extract it into a separate file. Search for "$productAttributesElement" to find the block with the functionality and for "productInfo" to find the part where I store the product data with the _json tags.

    Hi,
    No worries, Didnt know if you solved or the answer wasnt helpfull
    You need to trigger you script within the product details template layout, or you could add a listener to the product container and trigger the script if any changes are detected.
    Regards

Maybe you are looking for

  • I need help changing the account number my daughter uses for payment for her apps and itunes, etc. can anyone talk me through this.

    hi , im just a mom, not very computer savy.....however, I need to change the payment method my daughter uses to purchase things on her ipad due to the fact that the current one is expiring. ie: for such things like songs and games, etc. I would appre

  • How can I process a Sony A7 RAW file into Photoshop CS5.

    How can I process a Sony A7 RAW file into Photoshop CS5.  I tried the file DNG converter 8.3, but it did not work.  I was able to download it, but upon reading the memory chip from Photoshop CS5, it reads the jpg files fine, but not the RAW files.  I

  • Migration issue iMac to MacBook Pro

    Migrating data from iMac OS X Lion 10.7.5 to  new MacBook Pro.  Using ethernet and wifi connection to migrate.  MacBook has identified iMac for migration including code; but the iMac is not identifying the MacBook.  Any suggestions?

  • Truncated captions

    Ever since I changed my laptop to a new one with a screen resolution of 1600 x 900 , whenever I open a LV example it has the controls all squeezed up vertically in both FP and BD. With a result that the image is very difficult to read. See the exampl

  • Flash detects wrong version in one Mac account

    I have an iMac G5 with 2 user accounts on it. I go to http://www.adobe.com/software/flash/about/ to test the Flash version. In the main (admin) user account, it displays 10.1.102.64 In the second (managed) account, it displays 9.0.20.0 I tried uninst