struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abhiram <>
Subject Re: Dynamic combo boxes
Date Thu, 20 Sep 2007 17:10:37 GMT
i dont know anything about struts 2, but with my 1.2, i have no probs giving dynamic ids.

here is an idea.
inside ur jsp, keep incrementing a counter for every iteration. 
<%String s = "combo_" + counter;%>
give id as styleId="<%=s"
for two iterations, two combos with ids combo_1 and combo_2 will be created.proceed as u like.
if u feel that ids are irritating, use document.getElementsByTagName("input");
u will get an array.
check  type for each element.
if type is select, write a condition and do watever u want. 

.. and i din get "retrieve the particular combobox for a particular row right ?"

if u feel that i am not exactly getting wat u r trying 2 convey, pls present the probs in
greater detail
Maya menon <> wrote: Thanks for the response Abhiram,
  I tried using styleid,
  But how do I give [use] dynamic styleids ? There should be some way to retrieve the particular
combobox for a particular row right ?
  I tried using styleid=bean:write id=index> where index is retrieved from logic:iterator
  Have you tried it, This way the styleid was not getting dynamically populated

abhiram  wrote:
  ur requirement is to change contents of combobox 2, when a different option in combobox
1 is selected ryt..

i think you can give id to each combobox,write an onchange event or something similar to activate

in javascript, get the selected option of combobox 1 by using document.getElementById("id
of combo 1").value

write some condition on this value, and change the value of combobox 2 accordingly.

because u hardcode the ids, u can just access the comboboxes using their ids..this should
work whether ur comboboxes are static or dynamic.

Maya menon wrote: Hi all,

I have a page which displays dynamic comboboxes.
The records from DB will be displayed in table and two fields are getting displayed in comboboxes.

Now, there is one condtion in which if user changes something in first combobox then value
of second combobox should automatically change

I am capturing the value of the first combobox using this.value, using logic:iterator, indexid
and indexed=true to render the combo boxes.

How can I capture the second combobox in this case ?
How do I get the name of a dynamically rendered combobox in a javascript function

Here is how the second combobox gets created


Please provide inputs


Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on


Save all your chat conversations. Find them online.

Yahoo! oneSearch: Finally,  mobile search that gives answers, not web links. 


 Chat on a cool, new interface. No download required. Click here.
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message