| Author |
Pass parameter dynamically in Javascript in html:select
|
vicky kumar
Ranch Hand
Joined: Dec 13, 2002
Posts: 55
|
|
Hi, I have the following peace of code. How can I pass the current rowNum in iterate tage to onchange="handleSwapTypeChange(??)". <logic:iterate id="myBean" name="myForm" property="myList"> <tr bgcolor=#FFFFFF> <td valign="top"> <html:select name="myBean" property="myProp" indexed="true" onchange="handleSwapTypeChange(???)" > <html ptions collection="myList" property="value" labelProperty="label" /> </html:select> </td> </tr> </logic:iterate>
|
 |
Matthew Marquand
Ranch Hand
Joined: Dec 19, 2002
Posts: 32
|
|
Use the indexId="loopIndex" attribute of the logic iterate tag in conjunction with the "handleSwapTypeChange(<%= loopIndex %> ".
|
 |
vicky kumar
Ranch Hand
Joined: Dec 13, 2002
Posts: 55
|
|
Hi Mathew, "handleSwapTypeChange(<%= loopIndex %> ". prints the string as it is inside the html:select tag. So I am not getting loopIndex value printed. Are you sure you have tested this way. I have tried several ways to spit out scriplets inside struts-tags, but in vain. Could someone help. I have spent a lot of time figuring this out. Cheers Vicky
|
 |
Matthew Marquand
Ranch Hand
Joined: Dec 19, 2002
Posts: 32
|
|
Sorry about my previous post; I was posting from memory. It looks like we build complicated javascript invocations in a scriptlet: <% String onChangeJS = "handleSwapTypeChange('" + loopIndex + "');"; %> and then on your select: onchange="<%= onChangeJS %>"
|
 |
vicky kumar
Ranch Hand
Joined: Dec 13, 2002
Posts: 55
|
|
Thanks Mathew. Yes that's the only it works. I tried it before getting your reply. But your post confirms that this is the only way of achieving it. Wondering if struts-el offers spme solution without scriplets. Thanks again Cheers Vicky
|
 |
 |
|
|
subject: Pass parameter dynamically in Javascript in html:select
|
|
|