1

I am using this bit of jquery to put the value selected from my dropdown into a hidden text field. This works beautifully - got it from one of the folks on this forum!!!, but I just ran into a twist further in my code and I need to do the same thing, but this time I neeed to send the Display Text to another hidden filed that I will create. Using this code, what do I change to grab the display text instead of the associated value. for example if I have:

<select id="firstbox">
<option value="TM">Time Warner</option>
<option value="CC">Comcast</option>
<option value="HC">Hartford Cable</option>
</select>

How do alter the code below to grab and send "Time Warner", "Comcast" or "Hartford Cable"?

$(document).ready(function() {
        $("select#2135, select#4436, select#4437").change(function(){
            $("#4443").val($(this).val());
        })
        .trigger('change');
    });
user1176783
  • 673
  • 4
  • 19
  • 39

1 Answers1

4

Use .text() instead of .val() on the selected option

$(this).find(":selected").text()

ids should start with a letter, too

hunter
  • 62,308
  • 19
  • 113
  • 113