0

hello

i have this function to check all the checkboxes in the form.

function msgSCheck(){
chk = document.msgFList.msgCList;
if(document.msgFList.msgCheckCtrl.checked==true){
for (i = 0; i < chk.length; i++)
chk.checked = true ;
}else{
for (i = 0; i < chk.length; i++)
chk.checked = false ;
}
}

and input checkboxes like this one!

<input type="checkbox" name="msgCList" value="93287" />

like that works fine.
but i want to change the name in to name="msgCList[]" so i can get the value from al the checkboxs in that form..

chk = document.msgFList.msgCList[];
using this to check all the boxes i get an error.. what i need to do ?! please help me :) thanks

2
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by rajarajan07
0

Even you do this method, it is not possible to check all the box in a single line, again you are going to check the length like your above code. So both will same.

0

hi rajarajan , yes it works with the first one :) but if i change the name and i add [] to the end (for geting the value in PHP of all the checkboxes) javascript function stop works.. and don't check all the boxes, my script is like a MAIL so thats way i need all this checkboxes for DELETE options or others.. i have one checkbox that check or uncheck all the list <input type="checkbox" name="msgCheckCtrl" value="yes" onClick="msgSCheck();" />

0
<input type="checkbox" name="msgCheckCtrl[]" value="yes" onClick="msgSCheck();" />

for that you need to do as bove within the name attribute. Thats all.

0

noo i don't need the value of that checkbox in php, that one is only for check or uncheck all the other!

like this one: <input type="checkbox" name="msgCList" value="93287" />
using the name msgCList works!!

but if i change it in to <input type="checkbox" name="msgCList[]" value="93287" />

and change in the fuction
function msgSCheck(){
// This ONE
chk = document.msgFList.msgCList[];
//---------------------------------
if(document.msgFList.msgCheckCtrl.checked==true){
for (i = 0; i < chk.length; i++)
chk.checked = true ;
}else{
for (i = 0; i < chk.length; i++)
chk.checked = false ;
}
}

i get errors... the name msgCList[] , the problem is [ and ] .

0

if nobody knows how to solve this lets try to make some changes in PHP,

how can i get the value of multiple checkbox with the same name?!
<input type="checkbox" name="msgCList" value="value1" />
<input type="checkbox" name="msgCList" value="value2" />

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.