473,887 Members | 2,361 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

vikas251074
198 New Member
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
7 2050
vikas251074
198 New Member
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
198 New Member
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
16,027 Recognized Expert Moderator MVP
Do you mean client-side cookies using JavaScript or session variables?
Jun 13 '08 #4
vikas251074
198 New Member
Yes sir. Client side cookies using javascript or session variables.

Thanks and regards,
Vikas
Jun 13 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
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
198 New Member
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
16,027 Recognized Expert Moderator MVP
You're welcome. Glad you've got it working :)
Jun 13 '08 #8

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

Similar topics

4
21876
by: changed | last post by:
I have an application that works almost all of the time but there is an inconsistent error with some browsers (some Mac, some PC). It seems that the cookie won't get written before the redirect. If I turn on cookie prompting my computer will stall just after this cookie is written (if it's even written) *MOST* of the time. setCookie("FC2", escape(escape(getCookie("FC"))), "", "/", ".lacs.utexas.edu", false); window.location =...
0
1831
by: JT | last post by:
I posted a question earlier about communicating between a javascript function and vb.net. In the end I decided to try using a cookie. I use the following javascript function (from vb.net) to set the cookie: sb.Append("<script language='javascript'>") sb.Append("{if (confirm('Are you sure? ') == true)") sb.Append("{var date = new Date(); date.setTime(date.getTime()+(60*60*1000)); var expires = ' expires='+date.toGMTString();...
17
7086
by: Rabbit | last post by:
Hi, On my 1st page, i have a function which gets a new ID value and need to transfer to another immediately. which I want to get in 2nd page using Request.form("txtID"), but doesn't work, the returned value is "" Anybody know how to set this value on 1st page properly, in order to let 2nd page catch it? I don't want to use querystring to pass this value!
10
1679
by: _Who | last post by:
Given Request.Cookies and Response.Cookies in asp.net is there any reason to ever use javascript or any other method to use cookies? Thanks
0
9957
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9799
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11173
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10875
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9593
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7988
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7141
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5809
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4238
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.