PDA

View Full Version : Strange Problem..


Coral_Lover
10-17-2002, 07:32 AM
Hi, i've this really strange problem here. Hope u all can help me out. I've attached my coding. Ok, i'll highlight the problem here.
i declare a variable (var del) to capture the values of the selected checkboxes. So it's => del = document.Rep.elements[i].value, right? And it's suppose to capture the value of a certain checkbox. But the weird thing is: it always capture the value "on" now!! ARRGHH!! Why is this so?? Please tell me. And it works previously. That's why i'm very vex now!!

glenngv
10-17-2002, 07:38 AM
the value of the checkbox doesn't change whether it is checked or unchecked. what you want is to see which checbox is checked.

so it's:

if (document.Rep.elements[i].checked){
//do something
}

of course you need to check if it's a checkbox, so you need to add:

if (document.Rep.elements[i].type=="checkbox" && document.Rep.elements[i].checked){
//do something
}

Coral_Lover
10-17-2002, 07:40 AM
OOps.. sorry, i missed out the attachment. Ok, i've attached

Coral_Lover
10-17-2002, 07:48 AM
Hi Glenn, yes i did something similar to yours. And it works previously but now, i dunno y it keeps giving me this value "on" no matter what value i select. :mad: Coz i need to pass the values of the selected checkboxes to another JSP page to execute some other things...

glenngv
10-18-2002, 02:40 AM
as i said, the value of the checkbox DOESN'T change whether it is checked or unchecked.

when a checkbox is checked, its value is submitted to the server, when it is not checked, it will NOT be submitted to the server

so if you do a request.getParameter("nameOfCheckbox") and this checkbox is not checked, it will return null, if it is checked, it will return the value of the checkbox.

hope u understand.

Coral_Lover
10-18-2002, 02:53 AM
OOps... i found out the bug. :o Actually, it's juz bcos of VALIGN = 'CENTER' as i'm using out.println("<INPUT TYPE = 'checkbox'....STYLE = 'VALIGN: 'CENTER'....'"); So, it's bcos of ' '!! ARGGH!! So now, the codes work completely fine again. Thanks thanks!!