Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I've a struts2 checkboxlist as,
<s:checkboxlist list="{'Mon','Tue','Wed','Thur','Fri','Sat','Sun'}" name="processVO.weeklyCal" id="days" disabled="true"/>

But I'm not getting the id 'days' as I specified. id is showing like processVO.weeklyCal-1 upto processVO.weeklyCal-7, when I checked in page source. So I'm not able to write the jQuery function to enable/disable the checkboxlist using the id 'days'. How can I solve this? Pls help

Thanks
Posted
Comments
CRDave1988 7-May-12 5:53am    
can u show ur client side page source of checkbox.

hi--

use the getElementById function. in your case:

var days = document.getElementById("days");
 
Share this answer
 
By default checkboxlist uses the element name as id for the checkbox and label.
You have to use custom theme, and edit the checkboxlist.ftl file.

you need to make changes at two places:

1: default:
HTML
<input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}"
       id="${parameters.name?html}-${itemCount}"<#rt/>......

change to:
HTML
<input type="checkbox" name="${parameters.name?html}" value="${itemKeyStr?html}"
       id="${parameters.id?html}-${itemCount}"<#rt/>



(changes parameters.name to parameters.id), also for the lable to work correctly,
2: default:
HTML
<label for="${parameters.name?html}-${itemCount}" class... 

change to:
HTML
<label for="${parameters.id?html}-${itemCount}" class...

(again, parameters.name to parameters.id)

Note: i have extended simple theme. if you want to know how to create custom theme, the best way is to download and extract the struts2 core jar.
Goto /templates/simple, copy all files to your project dir: /templates/{theme name}

you can set the project default theme to the new theme, try googling if you need more info...
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900