I have a group of inputs to get player info:
<select name="playerSport" class="playerSport">...</select>
<input type="text" name="playerPosition" class="playerPosition" />
<input type="text" name="playerNumber" class="playerNumber" />
<button id="submit">Submit</submit>
There can be n number of each field. I'm using AJAX with this form so I want to pull each field into an array. Have an array for each sport, position, and number.
i've reviewed the examples from these pages: jquery.val() and jquery.map()
i've tried:
var sport = $('input[name="playerSport"').val() || [];
var sportList = sport.join(",");
var sport = $('.playerSport').val() || [];
var sportList = sport.join(",");
$('input[name="playerSport"').map().get().join(",");
$('.playerSport').map().get().join(",");
these return blank results. Odds are I'm missing something fairly obvious. Any ideas?
$('.playerSport').val()these will return you only one value and not an array then how can you do .join ???$('input[name="playerSport"')it should be$('input[name="playerSport"]')that is on the 1st line and the 7th line