Andrew, really appreciate your help but I still get the following when
viewing source (the generated html)
<input type="button" name="add[0]" value="Add to cart"
onclick="doSubmit(this.form, <%= index.toString() %>)"> </td>
I think the problem is the double quote - it prevents jsp/struts
from evaluating the anything within the quote...
Any thought to get around?
How do people use any index in logic:iterate normally?
thank
Zhao
(e-mail address removed) (Zhao) wrote in message David, sorry: that error was caused by something else. Now it
runs but the "<bean:write name=index/>" is never evaluated.
I see
<input type="button" name="add[0]" value="Add to cart"
onclick="doSubmit(this.form, '<bean:write name=BambooItemIndex/>')">
</td>
when view source of the generated html code.
Are you sure that we can use nested tags in this way?
thanks
Zhao
(e-mail address removed) (David W. Burhans) wrote in message (e-mail address removed) (Zhao) wrote in message I need to use the index number to construct a parameter of a script
call like
following (the second para of doSubmit)
<logic:iterate id="BambooItem" name="BambooListForm"
property="bambooItemList" indexId="index">
<tr>
...
<html:button property="add" value="Add to cart"
indexed="true" onclick="doSubmit(this.form,'<%=index%>')"/></td>
</tr>
...
</logic:iterate>
Use the <bean:write> custom tag to insert the value of index. Here is an example:
<logic:iterate id="BambooItem" name="BambooListForm"
property="bambooItemList" indexId="BambooItemIndex">
<tr>
<td>
<html:button property="add" value="Add to cart" indexed="true"
onclick="doSubmit(this.form,
'<bean:write name="BambooItemIndex"/>)"/>
</td>
</tr>
</logic:iterate>
It's not possible to nest tags in this manner. The onclick attribute
expects a string. <%= index %> evaluates to an Integer. Try
something like:
<html:button property="add" value="Add to cart" indexed="true"
onclick="doSubmit(this.form, <%= index.toString() %>)" />
Andrew
Duh - don't know what I was thinking...
<jsp:useBean id="posVEH" scope="request" class="Integer" />
<jsp:useBean id="posNDX" scope="request" class="Integer" />
<html:select property="<%= Globals.getVehicleMakeProperty(posVEH) %>"
onchange='<%= "onMakeChanged(" + posVEH.toString() + ")"%>'
tabindex="<%= posNDX.toString() %>" >
Assuming posVEH value is 2 and posNDX is 5 this generates the
following opening select tag:
<select name="vehicle[2].make" tabindex="5"
onchange="onMakeChanged(2)">
Hope this helps (this time)!
Andrew