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>

Was it helpful?

Solution

Try with

$('#groupsel').val(group);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top