Saturday, May 11, 2024
 Popular · Latest · Hot · Upcoming
40
rated 0 times [  45] [ 5]  / answers: 1 / hits: 40201  / 14 Years ago, fri, february 25, 2011, 12:00:00

I have been using the jquery serialize() function to serialize the values of a form and submit it via ajax



like for e.g. if the form name and id is factoryUsers



var data=$(#factoryUsers).serialize();



Now this works fine for forms that have text fields, text areas, simple drop downs etc.
But when I have a multiple dropdown , things go awry
for e.g. if I have a dropdown of the type



<select size=5 id=factoryUsers name=factoryUsers multiple=multiple>



the serialize doesn't work correctly anymore.
so if I select 3 users I get a query string like



factoryUsers=5&factoryUsers=23&factoryUsers=11



changing the select to array type doesn't help either factoryUsers[]



Any idea or help how to get this working correctly would be great.


More From » jquery

 Answers
225

The string output you've described above is the correct way of submitting multiple values for forms with the same name over HTTP, so jQuery is working correctly. It's up to you to handle how this is processed on the server-side, which is then dependent on what language you are using.



If you're using PHP, this may help: http://bytes.com/topic/php/answers/12267-how-php-_post-gets-multiple-values-html-form



Can you tell us what language you're using?


[#93579] Wednesday, February 23, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
stefanicarolinat

Total Points: 145
Total Questions: 91
Total Answers: 93

Location: Cambodia
Member since Thu, Oct 7, 2021
3 Years ago
stefanicarolinat questions
Mon, Nov 15, 21, 00:00, 3 Years ago
Fri, Apr 16, 21, 00:00, 3 Years ago
Thu, Oct 15, 20, 00:00, 4 Years ago
Fri, Jul 17, 20, 00:00, 4 Years ago
;