Using the JQuery :contains function to decide which option on a select is selected from a SESSION variable.
The contains function is matching the wrong option as their is an option 'PADI Open Water' and another 'PADI Open Water Scuba Instructor'
How do we limit it to match the exact content and no more?
$('option:contains("<?php echo $_SESSION['divelevel'];?>")').attr('selected', 'selected');
Try using .filter()
, to find the option you want.
$('option').filter(function(){
return $(this).html() == "<?php echo $_SESSION['divelevel'];?>";
}).attr('selected', 'selected');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With