Hi Slawek,
Thanx for ur suggestion...
Its working though the number of elements include other things apart from the number of rows in the table.


Thanx again
Sunil
----- Original Message ----- From: "Slawek" <[EMAIL PROTECTED]>
To: "MyFaces Discussion" <[email protected]>
Sent: Tuesday, February 22, 2005 1:26 AM
Subject: Re: How to get the value of selected checkboxes from a datatable injavascript?



hi

1. you can iterate by all elements of your form
2. you can check property "checked" of _every_ element
if element isnt checkbox it just havent property checked and if u try to get its value it will be created with defaullt value false


so...

isSomethingChecked=false;
for (i=0; i<document.form_name.elements.length; i++){
if (document.form_name.elements[i].checked){
isSomethingChecked=true;
break;
}
}

if (isSomethingChecked){
//ask user if he is sure to delete
}
else{
//probably do nothing
}

its lets say "pseudocode" ;) im not sure if it is ok, but i think that idea is ok...

BUT: it works only if there arent any other checkoboxes in your form

Sławek



Hi All,

I have a datatable and i have one checkbox on each row of the table.
There is a delete button which deletes all the checked rows.
I call a javascript on delete button which prompts the user : "are you sure you want to delete?"
Now the problem is that this message is displayed even without checking any row and it shd nt happen.
Now, how to get the value of selected check boxes in the javascript?
The number of checkboxes is determined at the runtime since its a datatable.


Has anybody come across this problem?

Looking forward to some advice on this topic.

Thanx and Regards,
Sunil




Reply via email to