Pre jquery I have used an id without the square brackets and a name with the square brackets. I used the id in my javascript and the form would submit with the name.
Ken On Feb 7, 6:28 am, Dave Stewart <[EMAIL PROTECTED]> wrote: > I'm finding it impossible using jQuery to select any attributes with > square brackets in them. > > I'm sure most people know PHP uses square brackets within form element > names to submit multi-dimensional arrays, ie: > > contact[name] > contact[email] > contact[telephone] > contact[options][option 1] > contact[options][option 2] > contact[options][option 3] > > This is read natively by PHP as: > > contact => array ( > name, > email, > telephone, > options => array( > option 1, > option 2, > option 3 > ) > ) > > In a way, jQuery's refusal to recognise square brackets makes sense, > as it leans towards attribute selectors (which are fantastic tools), > but vanilla getDocuementById() works, so I'm wondering why jQuery > hasn't some kind of check for this kind of thing? > > In the meantime, does anyone have any "best-practice" workarounds to > this issue, for example for the above data structure? > > Combined selectors, e.g. > > #contact-email > > and separate selectors e.g. > > #contact #email > > offer different advantages. Has anyone any preferences, and why?? > > Many thanks, > Dave Stewart