brodywx Posted March 28, 2007 Share Posted March 28, 2007 I know this doesn't relate to php right now, but eventually it will use php code. Still if someone could help me it would be much appreaciated. I want to know how to check/uncheck checkboxes using javascript. My checkboxes are part of a group (name="group[item]"). The items are random and not sequentially ordered in any way. I assumed this code would work, but it's giving me a page error: document.myForm.group[item].checked=1; Anyone? Quote Link to comment Share on other sites More sharing options...
mgs019 Posted March 29, 2007 Share Posted March 29, 2007 Have you tried checked="checked"; I know this works for selected="selected" so I assume it would for this too. Martin Quote Link to comment Share on other sites More sharing options...
brodywx Posted April 4, 2007 Author Share Posted April 4, 2007 Yes I tried that. I think it has something to do with the name group[item]. If the name was not an array type the line works just fine, but javascript doesn't like it when the checkbox name is an array, so has anyone ever done it before? I know it must be possible. Quote Link to comment Share on other sites More sharing options...
brodywx Posted April 4, 2007 Author Share Posted April 4, 2007 Ok I screwed that plan and decided to use the id value for the checkbox: document.getElementById('chkID').checked="checked"; This seems to be working alright. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.