Brob
Brob

Reputation: 675

jQuery multi-dimensional array name selector

Hi i'm trying to select a form input by name, however my form is setup to post into a multi-dimensional array

I'm trying to use

$('input[name=address[permanent][street]]')

to select the element but get the following response

Uncaught Error: Syntax error, unrecognized expression: input[name=address[permanent][street]]

Is this at all possible?

Upvotes: 3

Views: 4957

Answers (3)

kjdion84
kjdion84

Reputation: 10044

Use the starts with selector: '[name^="address"]'

Upvotes: 0

user2050909
user2050909

Reputation:

Try use $('input[name="address[permanent][street]"]') or $('input[name="'+ index +'"]') in your loop

Upvotes: 7

bipen
bipen

Reputation: 36531

try this

var strAddress=address[permanent][street];
$('input[name='+strAddress+']')

updated

$('input[name="address[permanent][street]"]')

if your name of input is address[permanent][street]

Upvotes: 0

Related Questions