S
Steve Darby
Hi all!
I wonder if anyone can help with a problem I am having with a sctipt I have
written. It uses the information stored in a cookie to generate a bar graph
of sales for a range of cooking pans. I have managed to read the cookie
information and draw the graph. The cookie is split and the values places
into two arrays. The cookie however, stores information on the preferences
for a text resizing facility in addition to the pan sales information. This
produces some unrequired information to be written to the graph. The
contents of the cookie is as follows:
sales=pan1=23,pan3=153,pan4=21,pan9=5; style=default
I only wish to use the information up to the semicolon, that is everything
other than style=default. How can I whilst splitting the cookie into the
two arrays, discard the unwanted information? Any help would be greatfully
received. Many thanks in advance. The script appears below:
<script language="javascript" type="text/javascript">
var array1 = new Array();
var array2 = new Array();
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.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);
document.write("<h2><u>"+array1[0]+"<\/u><\/h2><table>")
for (j=1; j<array1.length; j++) {
document.write("<tr><td><p><br><\/p><h3>"+array1[j]+"<\/h3><\/td><\/tr>")
document.write("<tr><td><img src='images/lilBlue.gif' height='20'
width='"+(array2[j-1]*3)
+"'>")
document.write(" "+array2[j-1]+"<\/td><\/tr>")
}
document.write("<\/table>")
</script>
I wonder if anyone can help with a problem I am having with a sctipt I have
written. It uses the information stored in a cookie to generate a bar graph
of sales for a range of cooking pans. I have managed to read the cookie
information and draw the graph. The cookie is split and the values places
into two arrays. The cookie however, stores information on the preferences
for a text resizing facility in addition to the pan sales information. This
produces some unrequired information to be written to the graph. The
contents of the cookie is as follows:
sales=pan1=23,pan3=153,pan4=21,pan9=5; style=default
I only wish to use the information up to the semicolon, that is everything
other than style=default. How can I whilst splitting the cookie into the
two arrays, discard the unwanted information? Any help would be greatfully
received. Many thanks in advance. The script appears below:
<script language="javascript" type="text/javascript">
var array1 = new Array();
var array2 = new Array();
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.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);
document.write("<h2><u>"+array1[0]+"<\/u><\/h2><table>")
for (j=1; j<array1.length; j++) {
document.write("<tr><td><p><br><\/p><h3>"+array1[j]+"<\/h3><\/td><\/tr>")
document.write("<tr><td><img src='images/lilBlue.gif' height='20'
width='"+(array2[j-1]*3)
+"'>")
document.write(" "+array2[j-1]+"<\/td><\/tr>")
}
document.write("<\/table>")
</script>