SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
Thread: Something weird
-
Sep 19, 2006, 08:28 #1
- Join Date
- Jun 2006
- Location
- Cape Town | South Africa
- Posts
- 117
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Something weird
Hi
I dont know why this is happening, but maybe it is supposed to happen. I have a checkbox on a page that when checked, checks all the others on that page, using getElementByTagName("input") and then checking it if the type attribute is checkbox. (tell me if you want me to post the code) This works perfectly normally, but as soon as I put a form field around it (which is neccesary) it says Object doesn't support this property or method. I have used the onclick attribute of the checkbox to execute the script, if that has something to do with it.
ThanksBen Sheard
-------------
Log all your dives easily and quickly from anywhere in the world
www.divinglogs.cafe150.com
-
Sep 19, 2006, 11:15 #2
- Join Date
- Sep 2006
- Location
- Indiana
- Posts
- 10
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I would need to see the code!
-
Sep 28, 2006, 13:46 #3
- Join Date
- Jun 2006
- Location
- Cape Town | South Africa
- Posts
- 117
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi
Here is the code:
Code:<body> <form action = "something.php" method="post" name="f"> <input type="checkbox" name="checkall" value="1" onclick="checkall(this)"><br><br> <input type="checkbox" name="check1" id="check1" value="1"><br> <input type="checkbox" name="check2" id="check2" value="1"><br> <input type="checkbox" name="check3" id="check3" value="1"><br> <input type="checkbox" name="check4" id="check4" value="1"><br> <input type="checkbox" name="check5" id="check5" value="1"><br> </form> </body>
Code:function checkall(id){ var inputs = document.getElementsByTagName('input'); for (var i = 0; i < inputs.length; i++) { if (inputs[i].getAttribute('type') == 'checkbox') { if (id.getAttribute('checked') == "") { inputs[i].setAttribute('checked', ''); } else { inputs[i].setAttribute('checked', 'checked'); } } } }
Ben Sheard
-------------
Log all your dives easily and quickly from anywhere in the world
www.divinglogs.cafe150.com
-
Sep 28, 2006, 15:14 #4
- Join Date
- Nov 2004
- Location
- Nelson BC
- Posts
- 2,310
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The name of your function is the same as the name attribute of the checkbox
-
Sep 29, 2006, 07:01 #5
- Join Date
- Jun 2006
- Location
- Cape Town | South Africa
- Posts
- 117
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks!!!!! It has been bugging me for days... it is finally working!!!
Ben Sheard
-------------
Log all your dives easily and quickly from anywhere in the world
www.divinglogs.cafe150.com
Bookmarks