dinosf
Technical User
- Dec 27, 2002
- 11
Hi guys - I have an issue (mainly that I know so little about javascript) in an asp.net page I am creating. On the page I have several drop down lists that I use the value of the selected value to create a cookie, then on page load I look for that cookie value and depending on what it is I know which drop down list was selected then I parse the string in the sub I call to complete the actions I need. The issue I'm having is getting rid of the cookie and/or setting it's value to nothing. I know I can set the timeout value to a negative value, and I've tried just using repsonse.cookies to change the value. So I'm thinking the problem is one with the path.
I don't know how to modify the cookie creation script to specify the path so when I use response.cookies it's not finding it. If javascript has a default path I might be able to access it with response cookies("../Path/"Values") = ""
or if someone has a better path to reccommend I'm all ears.
I don't need the cookie values after I retrieve them once, so removing it entirely works too. I do have a very specific reason for using cookies instead of regular asp.net session variables.
Here's how I add the value to the drop down list--------
Dim nli As New ListItem
nli.Value = arrR(q, 8)
nli.Text = intMos & " / " & intMiles
Dim strResult As String
strResult = "CreateCookie(this, 'TermCall');this 0].selected=true;"
ddlTerm.Attributes("onChange") = strResult
Me.ddlTerm.Items.Add(nli)
The script to create the cookie is in the html portion of the page -------
<SCRIPT language="JavaScript">
function CreateCookie(myListBox, varType)
{
var txtPlan;
txtPlan = myListBox[myListBox.selectedIndex].value;
document.cookie = "Values"+'='+varType+'|'+txtPlan;
}
</SCRIPT>
I need very specific help, as I seem to have a mental block on it today. Thanks.
I don't know how to modify the cookie creation script to specify the path so when I use response.cookies it's not finding it. If javascript has a default path I might be able to access it with response cookies("../Path/"Values") = ""
or if someone has a better path to reccommend I'm all ears.
I don't need the cookie values after I retrieve them once, so removing it entirely works too. I do have a very specific reason for using cookies instead of regular asp.net session variables.
Here's how I add the value to the drop down list--------
Dim nli As New ListItem
nli.Value = arrR(q, 8)
nli.Text = intMos & " / " & intMiles
Dim strResult As String
strResult = "CreateCookie(this, 'TermCall');this 0].selected=true;"
ddlTerm.Attributes("onChange") = strResult
Me.ddlTerm.Items.Add(nli)
The script to create the cookie is in the html portion of the page -------
<SCRIPT language="JavaScript">
function CreateCookie(myListBox, varType)
{
var txtPlan;
txtPlan = myListBox[myListBox.selectedIndex].value;
document.cookie = "Values"+'='+varType+'|'+txtPlan;
}
</SCRIPT>
I need very specific help, as I seem to have a mental block on it today. Thanks.