aspose file tools*
The moose likes JSF and the fly likes choose from SelectOneMenu, get the result in a SelectOneMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "choose from SelectOneMenu, get the result in a SelectOneMenu" Watch "choose from SelectOneMenu, get the result in a SelectOneMenu" New topic
Author

choose from SelectOneMenu, get the result in a SelectOneMenu

Legend Mvb
Greenhorn

Joined: Nov 11, 2009
Posts: 4
Hi, im doing web programming, and i was wondering how can i make
it like when i choose from a SelectOneMenu, then i get the result
from what i choosed in a new SelectOneMenu?

For example:

choose from this:

cycle -showing cycle first
car
bus
train

if i choose bus

i want the result like this:

cycle
car
bus -show bus first
train

i hope for any help, thanks
Akaine Harga
Ranch Hand

Joined: Nov 03, 2009
Posts: 79

Run a javascript function on onchange or onselect event that compares the values and set the selected property of the second field to the option that matches the original.


Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?
willCodeForFood("Java,PHP,C#,XML,VBS,XHTML,CSS,JavaScript,SQL"); //always looking for job opportunities in AU/NZ/US/CA/Europe :P
Legend Mvb
Greenhorn

Joined: Nov 11, 2009
Posts: 4
Akaine Harga wrote:Run a javascript function on onchange or onselect event that compares the values and set the selected property of the second field to the option that matches the original.

Im a noob:P
how do i set the value in SelectOneMenu?
i have it like this:

<h:selectOneMenu style="height:25;" value="#{enTreningsOkt.treningsokten.kategoriValgt}" >
<f:selectItems value="#{user.tempTreningsOkt.kategori.kategorier}"/>
</h:selectOneMenu>

thanks
Enrique Villamizar
Ranch Hand

Joined: Jul 30, 2005
Posts: 93
I have a similar problem: I need to know, in my back manage bean, what is the selected item. My selectOneMenu is created dynamically from a database query. By now I don’t have the answer yet.

I think the idea of Akaine is interesting…

Run a javascript function on onchange or onselect event that compares the values and set the selected property of the second field to the option that matches the original.


Nevertheless the javascript event should be onchange and also use additional hinding html element binding with the back manage bean. Don’t use onselect because that event is for textarea or textfield when the text is selected.

I’m looking for a better solution…please help.
Legend Mvb
Greenhorn

Joined: Nov 11, 2009
Posts: 4
I got it work when i select a categori, i got the selected categori in the other menu. But when im trying to
get a categori from a database, the selectOnemenu is showing the first categori and not the categori from the
database.

please help, thanks
Enrique Villamizar
Ranch Hand

Joined: Jul 30, 2005
Posts: 93
<h:selectOneMenu style="height:25;" value="#{enTreningsOkt.treningsokten.kategoriValgt}" >
<f:selectItems value="#{user.tempTreningsOkt.kategori.kategorier}"/>
</h:selectOneMenu>


I solved that problem this way:



The List has elements of type POJO representing the table in the database filled with the query(if not null).

Hope this could help.
Legend Mvb
Greenhorn

Joined: Nov 11, 2009
Posts: 4
Enrique Villamizar wrote:
<h:selectOneMenu style="height:25;" value="#{enTreningsOkt.treningsokten.kategoriValgt}" >
<f:selectItems value="#{user.tempTreningsOkt.kategori.kategorier}"/>
</h:selectOneMenu>


I solved that problem this way:



The List has elements of type POJO representing the table in the database filled with the query(if not null).

Hope this could help.

thank you very much, i will try it
 
 
subject: choose from SelectOneMenu, get the result in a SelectOneMenu