With some help from the community here, i was able to successfully get a jQuery function to grab the "val" of a selection of a drop down and do a conditional test with that value.
However the problem with using the <option value=""> is that the value is dynamically created and can be any number. So I have to use the text between the <option value=""></option> which doesn’t ever change. However, I cannot successfully obtain that text (.text()).
- Drop down with: class="choice"
- Drop down contains to options: "Someone Else" and "Me" as your two choices
- By default the drop down has "Me" selected. I need to see when the drop down changes (.change(function()) if "Someone Else" was selected.
NOTE: I have an alert ( ) there to return what is in the variable so I can see myself and it always returns blank.
Ok, so I made the following change and the variable "choice" now returns a value when the drop down selection changes. But the value of variable "choice" still doesn’t meet one of the two conditions ("Me" and "Someone Else"). The other oddity is that when I put in a "alert (choice)" to return the value it got it puts "Me" or "Someone Else" to the far right of the alert window.
var choice = jQuery(“.choice option:selected”).text();