I implemented some code (below) to check the state of ContentID and hide or show a DIV:
<select id="ContentID" name="ContentID">
<option selected="selected" value="00">Menu</option>
<option value="01">Topic</option>
</select>
<input id="htmlEdit" type="checkbox" />
$("#ContentID")
.val($.cookie("ContentID_dropdown"))
.change(function () {
if ($(this).val() == "00")
$("#htmlSwitch").show();
else
$("#htmlSwitch").hide();
$.cookie("ContentID_dropdown", $(this).val(), { expires: 365, path: '/' });
refreshGrid("Content");
});
This code works BUT only when the value of ContentID changes. What I need is something that will also check the value after the value has been changed with a cookie.
The code in the change function that checks .val() does not check anything or run when the initial value is set with a cookie. So if my cookie is for example set to Topic then it is ignored and the htmlSwitch DIV appears when it should not. Is there a way that I could make it check the initial value and also hide or show the htmlSwitch id?
What if you triggered it immediately after the
changeis bound?