Can anyone help with this problem. I am attempting to dynamically draw a
graph using data from a cookie. I have written the script to actually draw
the graph, for which I hav created two arrays with the data I required
preset into them. What I wish to do is split the cookie in which the data
is stored and create two array from it.
The function used to create the cookie is as follows
:function SetCookie(name, value) {
document.cookie = name + "=" + escape(value);
}
which is called with the following script:
<body onload="SetCookie('sales','pan1=23,pan3=153,pan4=2 1,pan9=5')">
I wish to create the following arrays by splitting the cookie:
array1=("sales","pan1","pan3","pan4","pan9")
array2=(23,153,21,5)
Can anyone help? Many thanks in advance. 11 1657
"Steve Darby" <ra****************@ntlworld.com> wrote in message
news:cY**************@newsfe6-win.ntli.net... Can anyone help with this problem. I am attempting to dynamically draw a graph using data from a cookie. I have written the script to actually
draw the graph, for which I hav created two arrays with the data I required preset into them. What I wish to do is split the cookie in which the data is stored and create two array from it.
The function used to create the cookie is as follows
:function SetCookie(name, value) { document.cookie = name + "=" + escape(value); }
which is called with the following script:
<body onload="SetCookie('sales','pan1=23,pan3=153,pan4=2 1,pan9=5')">
I wish to create the following arrays by splitting the cookie:
array1=("sales","pan1","pan3","pan4","pan9") array2=(23,153,21,5)
Can anyone help? Many thanks in advance.
What does your function "SetCookie()" look like?
Like this:
function SetCookie(name, value) {
document.cookie = name + "=" + escape(value);
}
"Steve Darby" <ra****************@ntlworld.com> wrote in message
news:In***************@newsfe6-win.ntli.net... Like this:
function SetCookie(name, value) { document.cookie = name + "=" + escape(value); }
If you do:
alert(unescape(document.cookie));
do you get this?
sales=pan1=23,pan3=153,pan4=21,pan9=5
"Steve Darby" <ra****************@ntlworld.com> wrote in message
news:In***************@newsfe6-win.ntli.net... Like this:
function SetCookie(name, value) { document.cookie = name + "=" + escape(value); }
Are you sure that you don't want:
array1=("pan1","pan3","pan4","pan9")
array2=(23,153,21,5)
isntead of:
array1=("sales","pan1","pan3","pan4","pan9")
array2=(23,153,21,5)
thus array1[0] and array2[0] will correspond to "pan1" and "23".
I need 'sales' to be in array1 as well as the rest as it is used to form the
heading of the bar chart
"Steve Darby" <ra****************@ntlworld.com> wrote in message
news:aH**************@newsfe6-win.ntli.net... I need 'sales' to be in array1 as well as the rest as it is used to form
the heading of the bar chart
Will this work for you?
<html>
<head>
<title>namevals.htm</title>
<script type="text/javascript">
var array1 = new Array();
var array2 = new Array();
function GetCookie() {
var what = unescape(document.cookie);
array1[0] = what.substr(0,what.indexOf("="));
what = what.substr(what.indexOf("=")+1);
var pair = what.split(",");
var j = 1;
var k = 0;
for (var i=0; i<pair.length; i++) {
var item = pair[i].split("=");
array1[j++] = '"' + item[0] + '"';
array2[k++] = item[1];
}
// display contents of both arrays:
what = unescape(document.cookie);
what += "\n\n array1 = " + array1.join(",");
what += "\n\n array2 = " + array2.join(",");
alert(what);
}
function SetCookie(name,value) {
document.cookie = name + "=" + escape(value);
}
</script>
</head>
<body onload="SetCookie('sales','pan1=23,pan3=153,pan4=2 1,pan9=5')">
<a href="javascript :GetCookie()">Get Cookie</a>
</body>
</html>
Will try it and let you know
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:IL********************@comcast.com... "Steve Darby" <ra****************@ntlworld.com> wrote in message news:aH**************@newsfe6-win.ntli.net... I need 'sales' to be in array1 as well as the rest as it is used to form the heading of the bar chart
Will this work for you?
<html> <head> <title>namevals.htm</title> <script type="text/javascript"> var array1 = new Array(); var array2 = new Array(); function GetCookie() { var what = unescape(document.cookie); array1[0] = what.substr(0,what.indexOf("=")); what = what.substr(what.indexOf("=")+1); var pair = what.split(","); var j = 1; var k = 0; for (var i=0; i<pair.length; i++) { var item = pair[i].split("="); array1[j++] = '"' + item[0] + '"'; array2[k++] = item[1]; } // display contents of both arrays: what = unescape(document.cookie); what += "\n\n array1 = " + array1.join(","); what += "\n\n array2 = " + array2.join(","); alert(what); } function SetCookie(name,value) { document.cookie = name + "=" + escape(value); } </script> </head> <body onload="SetCookie('sales','pan1=23,pan3=153,pan4=2 1,pan9=5')"> <a href="javascript:GetCookie()">Get Cookie</a> </body> </html>
Have run the script and the alert returns the following:
array1=,"","pan3","pan4","pan9"
array2=,153,21,5;style
And I should have mention that I am using script which allows me to change
text size on the page and saves the prefered values as a cookie, hence the
appearance of style in the second array. I am trying only to the
information listed for sales, if that makes sense
"Steve Darby" <ra****************@ntlworld.com> wrote in message
news:iY***************@newsfe6-win.ntli.net... Have run the script and the alert returns the following:
array1=,"","pan3","pan4","pan9" array2=,153,21,5;style
And I should have mention that I am using script which allows me to change text size on the page and saves the prefered values as a cookie, hence the appearance of style in the second array. I am trying only to the information listed for sales, if that makes sense
Would you change
alert(what);
to
document.write(what);
and post the results here.
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:JZ********************@comcast.com... "Steve Darby" <ra****************@ntlworld.com> wrote in message news:iY***************@newsfe6-win.ntli.net... Have run the script and the alert returns the following:
array1=,"","pan3","pan4","pan9" array2=,153,21,5;style
And I should have mention that I am using script which allows me to
change text size on the page and saves the prefered values as a cookie, hence
the appearance of style in the second array. I am trying only to the information listed for sales, if that makes sense
Would you change alert(what); to document.write(what); and post the results here.
Rather just add the following after the alert():
what = unescape(document.cookie);
what += "<br><br> array1 = " + array1.join(",");
what += "<br><br> array2 = " + array2.join(",");
document.write(what);
Here's what I get:
sales=pan1=23,pan3=153,pan4=21,pan9=5
array1 = sales,"pan1","pan3","pan4","pan9"
array2 = 23,153,21,5
"McKirahan" <Ne**@McKirahan.com> wrote in message
news:JZ********************@comcast.com... "Steve Darby" <ra****************@ntlworld.com> wrote in message news:iY***************@newsfe6-win.ntli.net... Have run the script and the alert returns the following:
array1=,"","pan3","pan4","pan9" array2=,153,21,5;style
And I should have mention that I am using script which allows me to
change text size on the page and saves the prefered values as a cookie, hence
the appearance of style in the second array. I am trying only to the information listed for sales, if that makes sense
I forgot the first element was supposed to quoted; try this:
<html>
<head>
<title>namevals.htm</title>
<script type="text/javascript">
var array1 = new Array();
var array2 = new Array();
function GetCookie() {
var what = unescape(document.cookie);
array1[0] = '"' + what.substr(0,what.indexOf("=")) + '"';
what = what.substr(what.indexOf("=")+1);
var pair = what.split(",");
var j = 1;
var k = 0;
for (var i=0; i<pair.length; i++) {
var item = pair[i].split("=");
array1[j++] = '"' + item[0] + '"';
array2[k++] = item[1];
}
what = unescape(document.cookie);
what += "<br><br> array1 = " + array1.join(",");
what += "<br><br> array2 = " + array2.join(",");
document.write(what);
}
function SetCookie(name,value) {
document.cookie = name + "=" + escape(value);
}
</script>
</head>
<body onload="SetCookie('sales','pan1=23,pan3=153,pan4=2 1,pan9=5')">
<a href="javascript :GetCookie()">Get Cookie</a>
</body>
</html>
You should get this:
sales=pan1=23,pan3=153,pan4=21,pan9=5
array1 = "sales","pan1","pan3","pan4","pan9"
array2 = 23,153,21,5 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Shannon Jacobs |
last post by:
I'm doing some trivial surveys, and I want to know if the same user
answers twice. Can't really know that, but at least I thought I could
check for the same browser/computer combination by using a...
|
by: chrism |
last post by:
Hello,
I have a pop-up window that I would like to appear in front of the
browser home page when a user opens IE. Problem is, I'd like it to
never appear again if the user navigates back to the...
|
by: brettr |
last post by:
When I reference document.cookie, there is a long string of key=value;
pairs listed. I may have 100 hundred cookies on my hard drive.
However, most only have one key=value pair. Does the...
|
by: socialism001 |
last post by:
I'm trying to store a value in a cookie but its not working. Can
anyone see what I might be doing wrong.
Thanks,
Chris
~~~~~~~~~~~~~~~~~~
<script language="javascript">...
|
by: Marco Krechting |
last post by:
Hi All,
I have a page with a list of hyperlinks.
I want to save information in a cookie about the fact that I entered an
hyperlink or not.
When I click one of the hyperlinks I want this stored...
| |
by: Wysiwyg |
last post by:
After a server created cookie is processed on the client I want it removed,
cleared, or expired in the javascript block but have been unable to do this.
If I set a cookie value in the server code...
|
by: CR1 |
last post by:
I found a great cookie script below, but don't know how to make it also pass the values sent to the cookie, to a querystring as well for tracking purposes. Can anyone help? If there was a way to...
|
by: kelvlam |
last post by:
Hello all,
I'm still a bit new with JavaScript, and I hope the guru here can shed
some light for me. It's regarding handling cookie and the
case-sensitive nature of JavaScript itself.
My...
|
by: shadow_ |
last post by:
Hi i m new at C and trying to write a parser and a string class.
Basicly program will read data from file and splits it into lines then
lines to words. i used strtok function for splitting data to...
|
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...
|
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,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |