• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

choose from SelectOneMenu, get the result in a SelectOneMenu

 
Legend Mvb
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 99
Java MyEclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Legend Mvb
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 93
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<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
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic