homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Checkbox values handled differently in PHP and Javascript
Adding square brackets after checkbox name disables Javascript functionalit

5+ Year Member

Msg#: 4408970 posted 1:19 pm on Jan 20, 2012 (gmt 0)

Hello everyone,

Can someone help me to solve this headache?

I have a couple of checkboxes created on the fly by a while loop from a database. The name attribute for the checkboxes is 'dsft' ( without square brackets for a reason i'm going to mention hereafter).

<tr><td><input type='chec



WebmasterWorld Senior Member penders us a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

Msg#: 4408970 posted 3:37 pm on Jan 20, 2012 (gmt 0)

(Your post looks truncated?)

What do you mean the "values handled differently"?

When square brackets occur in the name attribute (required for the benefit of PHP) you will need to refer to this element using square bracket notation in JavaScript, as opposed to object dot notation since "[" and "]" are invalid in identifiers.

// Returns a NodeList of all the name="mycheckboxes[]" controls on myform. 

Whereas if you weren't passing your values back to PHP then you wouldn't need to use square brackets, then you could use object dot notation:

// Returns a NodeList of all the name="mycheckboxes" controls on myform. 

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved