Try with
$('#groupsel').val(group);
Question
I store the previous submited value in a cookie. Now on page ready I want to switch the selected form option to the value I stored in the cookie.
This is what I've done so far but it does not work. Any ideas?
$(document).ready(function() {
// Cookie data: testgroup,december
var cookie = $.cookie('billForm');
var cookieArr = cookie.split(',');
var month = cookieArr[1]; // holds december
var group = cookieArr[0]; // holds testgroup
$('#groupsel select').val(group);
});
HTML
<form action="" method="post">
<select id="groupsel">
<option>foogroup</option>
<option>testgroup</option>
</select>
Solution
Try with
$('#groupsel').val(group);