Q:

how to check if a particular value was selected in select box

if i have a form with the following two elements.
<select name="" size="5" id="reasons" multiple="multiple">
    <option value="1">test1*</option>
    <option value="2">test2*</option>
    <option value="3">test3*</option>
    <option value="4">test4</option>
    <option value="5">test5</option>
</select>
<input type="checkbox" name="somecheckbox" id="checkboxId"/>

In the select box the users can select multiple things. 
Upon submit how can I check if the user has selected one of the options with '*' in the end and if they have then automatically checkmark the checkbox?
Is there a way to do this in jQuery?

A:

In plain javascript you'd do something like this:
var sel = document.getElementById('reasons');

for (var i = 0, l = sel.options.length; i < l; ++i) {
    if (sel.options[i].selected && sel.options[i].innerHTML.match(/\*/)) {
        document.getElementById('checkboxId').checked = true;
        break;
    }
}

