• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

skip value in logic: iterate

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic