3

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?

1
  • Could you provide the <form> please? In a jsfiddle perhaps. jsfiddle.net Commented Feb 20, 2013 at 9:32

3 Answers 3

7

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

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry I should have said I'm running this through a loop and set up like $('input[name='+ index +']') which can generates $('input[name=address[permanent][street]]') or $('input[name=forenames')
0

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]

2 Comments

Sorry I should have said I'm running this through a loop and set up like $('input[name='+ index +']') which can generates $('input[name=address[permanent][street]]') or $('input[name=forenames')
i am not getting you... you are saying in your loop the index=address[permanent][street]
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.