If your HTML is:
<select id="cmbOperator">
<option value="Jane">Jane</option>
<option value="John">John</option>
</select>
Use:
$("#cmbOperator option[value='" + name + "']").attr('selected', 'selected');
- Selects based on the
value
attribute.
or
$("#cmbOperator option:contains('" + name + "')").attr('selected', 'selected');
- Selects based on the text content.
If your HTML is:
<select id="cmbOperator">
<option>Jane</option>
<option>John</option>
</select>
Use:
$("#cmbOperator option:contains('" + name + "')").attr('selected', 'selected');