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>
Community
  • 1
  • 1

2 Answers2

1

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

Disha V.
  • 1,834
  • 1
  • 13
  • 21
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.

Muhammad Hassaan
  • 7,296
  • 6
  • 30
  • 50
Asim Shahzad
  • 1,438
  • 11
  • 18