Hi,
I have an odd problem that I'm trying to solve with jQuery. I have
select box with multiple options. Each of the options has a value, which
is a database id, and text which is what is displayed in the select box,
e.g.:
<select name="payment_method" id="payment_method">
<option value="">Please select:</option>
<option value="">-----------------------</option>
<option value="248">Phone me for payment details</option>
<option value="250">Secure Online Credit Card Payment</option>
</select>
The nature of the application means that the database id for each of the
options can change, while the text is unchanged. Because of this I need
to find a way to select the option by its text instead of its value. For
example I need to get the value for the option "Phone me for Payment
details" which in this case would return 248. I could then use the value
to select the option in the select element.
As far as I know I can't use the filter method to look for values, only
to filter by properties or class, so something like this doesn't work:
$("#payment_method").filter("Phone me for payment details").val()
Can anyone think of a way I can do this with jQuery?
Regards,
David