I have a drop down that I need to compare the values (the balance) inside of the drop down and compare this to a global variable, then performing an if / else statement to display some HTML.
Here is the drop down:
<select name="batch">
<option value='null'>-- None --</option>
<option value='96'>Check (#2200) (Bal. $84.00) - Jim Jones</option>
<option value='98'>Credit Card (#0) (Bal. $90.00) - Bailey Adams</option>
</select>
Here is my jquery:
$("select[name=batch]").change(function () {
if ($(this).val() >= GlobalTotal) {
$("th#show_refund").show();
$("th#no_show_refund").hide();
} else {
$("th#show_refund").hide();
$("th#no_show_refund").show();
}
});
Is it possible for jquery to ascertain what the balance is inside the HTML select? If so I appreciate a pointer to get me going in the right direction.
I assume you are constructing this dynamically. On each option, add an attribute
data-balance=84or whatever the balance is, then using jQuery, you would useSo, your complete code would be: