java - struts generating form elements from bean -
i have struts 1.2 bean , bean code below in jsp page
checkbox.jsp
<logic:iterate property="userlist" id="userdet" name="userdetails"> <html:checkbox property="checked" name="userdet" indexed="true"> <bean:write property="username" name="userdet"></bean:write> </html:checkbox> </logic:iterate>
the above code brings output below
now when submit form want carry out javascript validation using ids of checkbox.
how can generate id check box generated in jsp page bean?is possible generate id attribute dynamically ?
try using 'indexid' attribute (the name of page scope jsp bean contain current index of collection on each iteration. ) of
<logic:iterate>
and use inside 'styleid' attribute of
<html:checkbox>
like this:
<logic:iterate property="userlist" id="userdet" name="userdetails" indexid="checkboxindex"> <html:checkbox property="checked" name="userdet" indexed="true" styleid="checkbox<%= checkboxindex %>"> <bean:write property="username" name="userdet"></bean:write> </html:checkbox> </logic:iterate>
Comments
Post a Comment