Default Function Value from a Cookie

E

evanburen

When my page loads, I check for the existence of a cookie value through
readCookie(). If there is a value present for the cookie, I would like
that to be the default value in function ordering() and that value to
be the SELECTED value in ddlProfileNames. In other words, if there is
no cookie value, then function ordering will default to
ordering("Div1,Div2,Div3,Div4"). If there is a value, then that should
be used in function ordering and as the default value in
ddlProfileNames. Thanks for any help.

<body onLoad="readCookie('default')">

<FORM name="frmProfileNames">
<SELECT class="smalltext" id="ddlProfileNames"
onChange="ordering(this.options[this.selectedIndex].value);">
<option value="Div1,Div2">1 & 2</option>
<option value="Div3,Div4">3 & 4</option>
<option value="Div1,Div2,Div3,Div4" SELECTED>All Sections</option>
</SELECT>
<a href="#" onclick="setCookie('default', 30);return false">Save as
Default Profile</a>
</FORM>


<SCRIPT>
function ordering(sorder)
{
// code here
}

// start things off:
ordering("Div1,Div2,Div3,Div4");

</SCRIPT>
 
S

Stephen Chalmers

When my page loads, I check for the existence of a cookie value through
readCookie(). If there is a value present for the cookie, I would like
that to be the default value in function ordering() and that value to
be the SELECTED value in ddlProfileNames. In other words, if there is
no cookie value, then function ordering will default to
ordering("Div1,Div2,Div3,Div4"). If there is a value, then that should
be used in function ordering and as the default value in
ddlProfileNames. Thanks for any help.
If the cookie has a value, loop through all the values in the select
and compare
them to the cookie's value. If a match is found, set the selectedIndex
property
to the current value of the loop counter and optionally call
ordering(), passing the currently indexed value as the parameter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top