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

enter image description here

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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -