I need to change the selected option with the value coming from the database.
Here is the code:
// this code is in ondeviceready function.
function onDeviceReady() {
$("#txtgender2").val(data.data.gender).selectmenu("refresh");
}
This code is in somewhere in div
<div>
<select name="txtgender2" id="txtgender2" data-role="slider">
<option value="Male" >Male</option>
<option value="Female">Female</option>
</select>
</div>
How do I change the selected option of the selectmenu
?
If you want to refresh the select menu with data-role slider you have to use:
$("#txtgender2").val(data.data.gender).slider("refresh");
instead of:
$("#txtgender2").val(data.data.gender).selectmenu("refresh");