I am creating an select like this:
<select id="teamNameLabel" data-corners="false" onchange="GetSelectedTeam()" data-bind="options: teams, optionsText: 'name', optionsValue: 'id'">
<option value="1">Select a Team...</option>
</select>
My application is a single page, so when an option is selected it is assigned to TeamId like this:
TeamId = $('#teamNameLabel').val();
I would like the selected option to be what was last selected when you navigate back to this page. I tested it with this when the page loaded, but the alert keeps coming back as undefined
.
$("#teamNamelabel option").eq(TeamId+1).attr("selected","selected");
alert($("teamNameLabel option:selected").val());
Is there anyway i can set the selectedOption or .attr(selected) to be TeamId?