Hey,
Im at my wits end!
Im trying to get IE to store a string that defines a multi-demensional array as an actual array.
Heres what the array definition would look like: -
foo = Array( {'key' : 'value', 'key2' : 'value2'},{'key' : 'value', 'key2' : 'value2'}, {'key' : 'value', 'key2' : 'value2'}, {'key' : 'value', 'key2' : 'value2'});
-
alert(foo[1]["key"]);
-
No problem!
but i have this stored as a string (without the foo = part). So im using eval() to evaluate the code. It's worked in most combinations i've tried in firefox no problems but none in IE. Heres some of what ive tried: -
foo = "Array( {'key' : 'value', 'key2' : 'value2'},{'key' : 'value', 'key2' : 'value2'}, {'key' : 'value', 'key2' : 'value2'}, {'key' : 'value', 'key2' : 'value2'});";
-
-
foo = "\"Array( {\"key\" : \"value\", \"key2\" : \"value2\"},{\"key\" : \"value\", \"key2\" : \"value2\"}, {\"key\" : \"value\", \"key2\" : \"value2\"}, {\"key\" : \"value\", \"key2\" : \"value2\"});\";";
-
-
foo = "\"Array( {'key' : 'value', 'key2' : 'value2'},{'key' : 'value', 'key2' : 'value2'}, {'key' : 'value', 'key2' : 'value2'}, {'key' : 'value', 'key2' : 'value2'});\"";
-
-
-
myarray = eval(foo);
-
alert(myarray[1]["key"]);
-
To further complicate things, some of the values in the array sometimes have ' characters in, however i just want to get it working without first then i can probably just add slashes to solve that problem.
Any Help is much apprieciated!
Andy
3 4825 gits 5,390
Expert Mod 4TB
hi ...
i just tested it in IE6 addressbar: - javascript:var a = eval("Array( {'key' : 'value', 'key2' : 'value2'},{'key' : 'value', 'key2' : 'value2'}, {'key' : 'value', 'key2' : 'value2'}, {'key' : 'value', 'key2' : 'value2'});"); alert(a[0].key);
that was your first showed option and it alerted 'value' as it would be expected? ... what IE version do you use? is any error shown?
kind regards
oh yea, should have thought about testing it like that,
turns out it was a problem with my variable name and another class that i wrote conflicting.
Thanks for your help!
gits 5,390
Expert Mod 4TB
no problem ;) ... post back to the forum anytime you have more questions ...
kind regards
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JesusFreak |
last post by:
From: us_traveller@yahoo.com (JesusFreak)
Newsgroups: microsoft.public.scripting.jscript
Subject: toolbar script problem
NNTP-Posting-Host: 192.92.126.136
Recently, I downloaded the following...
|
by: Marci |
last post by:
I found this script for cascading menus, however, I cannot reach the
author to solve the bug I am having when I add a second menu to it.
My problem is this:
If I click on the first link, the...
|
by: binnyva |
last post by:
Hello Everybody,
I am writing an interactive tutorial for JavaScript.
I created a text box into which the users can input
javascript commands. On pressing a button, these commands
will be...
|
by: jimmygoogle |
last post by:
I posted earlier with a scope problem. I think I resolved it in IE but
in Firefox it still exists. Anyone have any ideas/experience with
this? I attached my code sorry it is so long. You can...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |