0

These links:

"How to modify an HTML Select when the name is an array using Javascript"

and "How to pass an array from HTML to Javascript?"

blinds me on what if i have select tags with 2 or more different names like:

<select name='category[123]'>
    <option value='0'>off</option>
    <option value='1'>on</option>
</select>

<select name='category[456]'>
    <option value='0'>off</option>
    <option value='1'>on</option>
</select>

<select name='anothercategory[123]'>
    <option value='0'>off</option>
    <option value='1'>on</option>
</select>

<select name='anothercategory[456]'>
    <option value='0'>off</option>
    <option value='1'>on</option>
</select>
1
  • Do you need this values with ajax request or form submission? Commented Aug 17, 2015 at 4:30

2 Answers 2

1

You can use $("form").serialize() for posting all values from the form.

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

2 Comments

i'm testing something like stackoverflow.com/questions/10398783/…
and data : $('form').serialize() + "&othervariable=othervarvalue" works!
0

If you need to get values one by one you can use this example as well.

var category_id    = $('#category').val()
var form_data      = { category : category_id };
data    : form_data,

Now you can get category values where you need it.

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.