I'm looking to return a CSV formatted string to set the value of a input text field with the OPTION values from a SELECT box.
$.map($('#addedchargeamtid option'), function(e) { var exp = $(e).text(); alert(exp); })
In using a map function but it looks to overwrite the value each time. can't figure out how to concat these together somehow.
BTW thanks to all the jQuery Gurus today, much props on my issues!!!
UPDATING:
<option value="123">123</option>
<option value="asd">asd</option>
<option value="trr">trr</option>
<option value="345">345</option>
I need this:
123,asd,trr,345
But the options are dynamic and can be added or removed, so there could be 1 or 100
NEW:
Well this is kinda working. it gives me 4 options of the same item when I only added it once. also does not update the hidden text field with the CSV value
// Add remove button
$('#addButton').click(function() {
$('#removeButton').show();
// Add
var myOptions = $('#typedchargeamtid').val();
$.each(myOptions, function() {
$('#addedchargeamtid').append(
$('<option></option>').val(myOptions).html(myOptions)
);
});
var txt = $('#addedchargeamtid').val() || [];
$('#commasepchargeamtid').val(txt.join(','));
});
Thanks again