/    Sign up×
Community /Pin to ProfileBookmark

check Boxes in jsp

Hi Techies,
I am creating check boxes in a for loop.
Here is my code.

<%
Iterato kkIterator = ruleList.iterator();
while(kkIterator.hasNext())
{
String kkName = kkIterator.next().toString();
%>
<input type=”checkbox” name=”kkCheckBoxes” value =”<%=kkName%>” ><%=kkName %>
<%
}
%>

I want to put one option like checkAll and deselectCheckBoxes. I check checkAll check box , all the check boxes should be checked.
If i check Deselect, the all the check boxes should be unchecked.

How can I do this one??

regards,
Krish

The java script I am writting is
function selectAll(){
if(frm.checkAll.checked){
if(!frm.kkCheckBoxes[0]){//single check-box
frm.check_StudentId.checked = true;
}
else{//array of check-boxes
for(var i=0; i<frm.kkCheckBoxes.length; i++){
frm.kkCheckBoxes[i].checked = true;
}
}
}
else{
if(!frm.kkCheckBoxes[0]) { // single check-box
frm.kkCheckBoxes.checked = false;
}
else{//array of check-boxes
for(var i=0; i><frm.kkCheckBoxes.length; i++) {
frm.kkCheckBoxes[i].checked = false;
}
}
}
}

But this script I am getting error Object expected.
Can u guys tell me am i missing some thing in my code

regards,
krish

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisJul 14.2006 — Are you sure that your test for a single checkbox works? I know that I have had success testing the "length" attribute, but I never tried looking for "[0]".

You can get "object expected" for just about any reason. When you look at the source, do you see the checkboxes in the code? Are there any typos?

Where do you set up the variable "frm"? I don't see it in your code.
Copy linkTweet thisAlerts:
@krish123authorJul 14.2006 — i just implemented the java script from google. I dont know any thing about it

ok

My aim is to i will place one check box ,if i select this check box , what ever the check box i am getting from the for loop , all of them should be selected.

How can i do this one
×

Success!

Help @krish123 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...