get the values of the combo fields before recording

0

I have an html table with N values and I would like to get the values of the fields (combo), property name = 'caption []' before writing, just to display to the user the fields that it filled in.

    
asked by anonymous 30.05.2016 / 14:31

2 answers

1

When you press the button to display the choices, you will have to scroll through the elements to see what the value is in each:

$('#check').on('click', function() {
  var escolhas = '<b>As suas escolhas são:</b><br>';
  $('select').each(function() {
     escolhas += $(this).prop('id')+ ': ' +$(this).val()+ '<br>';
  });
  $('#present').html(escolhas);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><selectid="select1">
  <option></option>
  <option value="Maria">Maria</option>
  <option value="Miguel">Miguel</option>
  <option value="Sara">Sara</option>
  <option value="Claudia">Claudia</option>
</select>
<select id="select2">
  <option></option>
  <option value="Maria">Maria</option>
  <option value="Miguel">Miguel</option>
  <option value="Sara">Sara</option>
  <option value="Claudia">Claudia</option>
</select>
<select id="select3">
  <option></option>
  <option value="Maria">Maria</option>
  <option value="Miguel">Miguel</option>
  <option value="Sara">Sara</option>
  <option value="Claudia">Claudia</option>
</select>
<br>
<button id="check">
Verificar Escolhas
</button>
<div id="present">
 
</div>

Example HERE

    
30.05.2016 / 15:45
0

try using the following code

  var valores = $('select[name^=legenda]').map(function(idx, elem) {
    return $(elem).val();
  }).get();

it will return an Array with all values of all fields within the values variable

    
30.05.2016 / 15:07