Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
133
rated 0 times [  136] [ 3]  / answers: 1 / hits: 22137  / 14 Years ago, thu, march 10, 2011, 12:00:00

How to store this value in session?



My grid has 3 pages.. with page size 50 when I change this dropdown list box in first page it's doing perfect. but when I got to second page I am not seeing selected value for this dropdown list boxes?



Is there any way that we can maintain seession for this dropdownlist box value to send to the next page to set?


More From » jquery

 Answers
2

By session, do you mean your server-side session variable? If so, you would need to send a post to a page of your language of choice, parse out the variable, and then on the next page, read the session variable and set the option selection accordingly.



If by session, you mean keeping the same option on the client side, this could easily be accomplished by setting a cookie on the clients machine through javascript and then read it in on the next page, or to send a query string along with the url of the next page.



EDIT



If there is no automatic post, I would recommend setting a cookie when a option is chosen.



Here is some pseudocode you can adapt to work for you: (more on javascript cookies @ w3schools )



<option onclick=setcookie(#id)>
function setCookie(choice){
document.cookie=option= + choice;
}


next page:



$(document).load(checkCookie());
function getCookie(option)
{
var i,x,y,ARRcookies=document.cookie.split(;);
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf(=));
y=ARRcookies[i].substr(ARRcookies[i].indexOf(=)+1);
x=x.replace(/^s+|s+$/g,);
if (x==option)
{
return unescape(y);
}
}
}
function checkCookie()
{
var option=getCookie(option);
if (option!=null && option!=)
{
$(option).selected();
}
}

[#93339] Wednesday, March 9, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
arthur

Total Points: 729
Total Questions: 107
Total Answers: 109

Location: China
Member since Mon, Aug 22, 2022
2 Years ago
;