By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,435 Members | 2,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,435 IT Pros & Developers. It's quick & easy.

Can I assign value to cookies immediately after selecting a value from list

vikas251074
100+
P: 198
Can I assign value to cookies immediately after selecting a value from list?

Expand|Select|Wrap|Line Numbers
  1. <select name="vlan_name" style="width:150px ">
  2. <%set rs = conn.execute("select vlan_name from vlan_master order by vlan_name")
  3.   dim v_lan
  4.   do while not rs.eof%>
  5.     <option value="<%=rs("vlan_name")%>"><%=rs("vlan_name")%></option>
  6. <%  rs.movenext
  7.   loop%>
  8. </select>
Thanks and regards,
Vikas
Jun 13 '08 #1
Share this Question
Share on Google+
7 Replies


vikas251074
100+
P: 198
I am giving you code below. Here can I store value passed in vlan function in session variable?

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. var xmlHttp
  3.  
  4. function vlan(str){ 
  5.   xmlHttp=GetXmlHttpObject();
  6.   if (xmlHttp==null)  {
  7.     alert ("Your browser does not support AJAX!");
  8.     return;
  9.   } 
  10.   var url="getvlan.asp";
  11.   url=url+"?q="+str;
  12.   url=url+"&sid="+Math.random();
  13.   xmlHttp.onreadystatechange=stateChanged;
  14.   xmlHttp.open("GET",url,true);
  15.   xmlHttp.send(null);
  16. }
  17.  
  18. function vitem(str){ 
  19.   xmlHttp=GetXmlHttpObject();
  20.   if (xmlHttp==null)  {
  21.     alert ("Your browser does not support AJAX!");
  22.     return;
  23.   } 
  24.   var url="getip.asp";
  25.   url=url+"?q="+str;
  26.   url=url+"&sid="+Math.random();
  27.   xmlHttp.onreadystatechange=stateChanged;
  28.   xmlHttp.open("GET",url,true);
  29.   xmlHttp.send(null);
  30. }
  31.  
  32. function stateChanged() { 
  33.   if (xmlHttp.readyState==4)
  34.     { document.getElementById("txtHint").innerHTML=xmlHttp.responseText;}
  35. }
  36.  
  37. function GetXmlHttpObject(){
  38.   var xmlHttp=null;
  39.   try { xmlHttp=new XMLHttpRequest();  }   // Firefox, Opera 8.0+, Safari
  40.   catch (e){ try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}   // Internet Explorer
  41.   catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
  42. }
  43. return xmlHttp;
  44. }
  45.  
  46. function menu(){
  47.   window.location = "menu.asp";
  48. }
  49. </script>
Thanks and regards,
Vikas
Jun 13 '08 #2

vikas251074
100+
P: 198
I have modified the line no. 1 as below

Expand|Select|Wrap|Line Numbers
  1. <select name="vlan_name" style="width:150px " onchange="vlan(this.value);">
And this vlan() function is called and described as below. Can I store this value passed in vlan function in session variable? How


Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. var xmlHttp
  3.  
  4. function vlan(str){ 
  5.   xmlHttp=GetXmlHttpObject();
  6.   if (xmlHttp==null)  {
  7.     alert ("Your browser does not support AJAX!");
  8.     return;
  9.   } 
  10.   var url="getvlan.asp";
  11.   url=url+"?q="+str;
  12.   url=url+"&sid="+Math.random();
  13.   xmlHttp.onreadystatechange=stateChanged;
  14.   xmlHttp.open("GET",url,true);
  15.   xmlHttp.send(null);
  16. }
  17.  
  18. function vitem(str){ 
  19.   xmlHttp=GetXmlHttpObject();
  20.   if (xmlHttp==null)  {
  21.     alert ("Your browser does not support AJAX!");
  22.     return;
  23.   } 
  24.   var url="getip.asp";
  25.   url=url+"?q="+str;
  26.   url=url+"&sid="+Math.random();
  27.   xmlHttp.onreadystatechange=stateChanged;
  28.   xmlHttp.open("GET",url,true);
  29.   xmlHttp.send(null);
  30. }
  31.  
  32. function stateChanged() { 
  33.   if (xmlHttp.readyState==4)
  34.     { document.getElementById("txtHint").innerHTML=xmlHttp.responseText;}
  35. }
  36.  
  37. function GetXmlHttpObject(){
  38.   var xmlHttp=null;
  39.   try { xmlHttp=new XMLHttpRequest();  }   // Firefox, Opera 8.0+, Safari
  40.   catch (e){ try {xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}   // Internet Explorer
  41.   catch (e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
  42. }
  43. return xmlHttp;
  44. }
  45.  
  46. function menu(){
  47.   window.location = "menu.asp";
  48. }
  49. </script>
Thanks and regards,
Vikas
Jun 13 '08 #3

acoder
Expert Mod 15k+
P: 16,027
Do you mean client-side cookies using JavaScript or session variables?
Jun 13 '08 #4

vikas251074
100+
P: 198
Yes sir. Client side cookies using javascript or session variables.

Thanks and regards,
Vikas
Jun 13 '08 #5

acoder
Expert Mod 15k+
P: 16,027
This link should help explain how to use cookies, set them, read them and delete them. If you have any problems, just ask.
Jun 13 '08 #6

vikas251074
100+
P: 198
Yes sir, this link is very useful for beginners. Now I am able to create cookies in javascript.

Thanks and regards,
Vikas
Jun 13 '08 #7

acoder
Expert Mod 15k+
P: 16,027
You're welcome. Glad you've got it working :)
Jun 13 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.