Get text from select when cycling through each input
<p>I am grabbing all inputs from a 5 tab form.  When cyclying through them I am adding them to a review section.  I have it working fine but I want to show the text of the select drop downs rather then the value as the value would not make sense to the user.  Here is a couple of snippets of code I am using.  This is inside and $(:input.each(function(){}  I check to see if it is a select.  If so I set a tmp variable and add on '_in' to the name as I have all field names plus that on the confirm tab.  Then I check the length of the new variable to make sure it is on the confirmation tab.  If so update the html to the text.  The issue is it shows all drop down text options.  If I do .val() it gives only the value of the selected one.  </p>

<pre><code>//Gives all text options from the drop down.
if ($(this).prop('type') == 'select-one') {
  var tmp = '#'+$(this).attr('name')+'_in';
  if ($(tmp).length &gt; 0) {
    $(tmp).html($(this).text());
  }         
}

//Gives only value of selected option from drop down.
if ($(this).prop('type') == 'select-one') {
  var tmp = '#'+$(this).attr('name')+'_in';
  if ($(tmp).length &gt; 0) {
    $(tmp).html($(this).val());
  }
</code></pre>

<p>Fixed solution</p>

<pre><code>if ($(this).prop('type') == 'select-one') {
  var tmp = '#'+$(this).attr('name')+'_in';
  var tmp2 = '#'+$(this).attr('name')+' option:selected';
  if ($(tmp).length &gt; 0) {

tmp3 = $(tmp2).text();
$(tmp).html(tmp3);
}           
}
</code></pre>
