views:

6

answers:

0

Hello yet again! I created a ajax/ coldfusion select menu in my header on my website that allows one to select a department. This sets a session variable to the department ID. I want to be able to take my "datas" which contains the value of the select box and make sure that variable is applied to the selectlist everytime the header is displayed. (Which is on every page). So, basically I want to cache the value of the select list.

I found a jquery cookie plugin that I think can accomplish this, but I'm not sure how to really do it. I tried a few times and nothing worked.

So far I have:

$(document).ready(function() {


$.cookie('selectCookie');



$('#dept').change(
        function() {

            var datas = $(this).val();
            var urlDept = 'catch.cfm?dept=' + datas;
            $.ajax({
            type: 'post',
            url: urlDept,
            success: function(){
            $cookie('selectCookie', datas);
            location.reload();

            }
             });
}); 

});

//////

<form>
    <select name="DeptCode" id = "dept">
    <option value="NONE">Choose a Department
    <cfoutput query="getDepartments">
    <option value="#DeptCode#">#DeptName#</option>
    </cfoutput>
    </select>
 </form>

Yes, I know I could have done this with cfform easily, but there is reasons for doing it this way. :)