Forum Moderators: open

Message Too Old, No Replies

Checking checkbox

problem with double change

         

mcibor

3:23 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a dynamically generated table with checkboxex.
<form name="z" id="z" method="POST" action="z.html"> <table><tr onclick="javascript:if(document.z.c1.checked == 1) document.z.c1.checked = 0; else document.z.c1.checked = 1;">
<td><input type="checkbox" name="c1" id="c1"></td></tr></table></form>

Certainly there are many more columns that's why I put onclick into <tr>.
However here comes the problem:
When I click on the checkbox it doesn't check, because mouse checks it and javascript unchecks it. What to do?
(I can check the checkbox by clicking anywhere in the row, but checkbox).

Help please!
Michal Cibor

Rambo Tribble

4:16 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You might try putting an onclick script on the checkbox that cancels bubbling.

mcibor

5:48 pm on Mar 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Rambo!

It works now (I just put into the <input> the same onclick as in <tr>). I'm sure there's a simpler way to do it, but it works.

Happy Easter!
Michal Cibor