Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

skip value in logic: iterate

 
Nimish Patel
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have two dropdown box(combo box) in one jsp.

In first combo box, I iterate one ArrayList comes from Action class.

In List , I set Property's name and ID.

Propertyname is displayed in combo box.

and propertyID is set in <option> tag's value attribute.

code for first combo box :-
--------------------------------------------------------------------------
<logic:iterate id="prop" name="lstprops">

<bean efine id="iptID" name="prop" property="PropertyID"/>

<option value='<%=String.valueOf(iptID)%>'><bean:write name="prop" property="name"/></option>

</logic:iterate>

----------------------------------------------------------------------
After select one propertyname in the first combo box, now I want to iterate same list in second combo box.

but In second combo box should not be contain "propertyname" which I have selected in first combo box.

How can I do that ?

can I use logic:equal tag ? but How ?

Please help me.

Thanks,
Nimish Patel
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best way to handle this would be through JavaScript. Think about it: When the server is composing the page, you don't know which option the user is going to select for the first dropdown. The only option for using server-side code would be to submit the page as soon as the user selects an option from the first dropdown, populate the second dropdown without the option from the first dropdown, and redisplay the page.

The javascript solution would be something like this:

1. on the server-side, just populate both dropdown options exactly the same.
2. When the user selects an option from the first dropdown (using the onchange event) save the option selected in a variable, and then iterate through the options in the second dropdown and remove the one that matches the one selected in the first dropdown.
3. If the user changes the first dropdown again, in the second dropdown you will have to replace the option you removed in step 2, and then remove the newly selected option.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic