0

How can I send multiple values (ie., values from multiple drop down) as a string separated by commas, using JavaScript while submitting a form.

I have a set of values which has to be selected based on the drop down selection, like if the value is 1 I have to send 5609, if the value is 2, 5610. I have arrays for this data.

If we select values 1 and 2 then the string that has to be created is 5609,5610

<select multiple id="value">
  <option value="1">Car</option>
  <option value="2">Bus</option>
  <option value="3">Bike</option>
  <option value="4">Van</option>
</select>
kshetline
  • 12,547
  • 4
  • 37
  • 73
  • where do `5609` and `5610` come from – Isaac Apr 11 '18 at 02:24
  • I have a string like this 1#5609,2#5610,3#5611 from database. which I am splitting and storing in an array. – charan teja Apr 11 '18 at 02:33
  • how does that relate to the ` – Isaac Apr 11 '18 at 02:35
  • based on the value that is selected from the drop down. – charan teja Apr 11 '18 at 02:37
  • Why don't simply change the value to `5609...`? Why not doing the mapping on the server side as you mention it's from the database? If you really want do mapping after the submit maybe you need this https://stackoverflow.com/questions/4517366/change-form-values-after-submit-button-pressed#answer-4517383 – JustWe Apr 11 '18 at 02:52

0 Answers0