?
Solved

eval in Netscape does not work properly

Posted on 2006-06-01
7
Medium Priority
?
289 Views
Last Modified: 2009-07-29
I have the following code:
var VendorId123Array = ....
...
var vendorId  = 123;
var selectedArray = eval("VendorId" + vendorId + "Array");

in Netscape selectedArray is null, why?
In IE  - works OK
0
Comment
Question by:netformx
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 10

Expert Comment

by:iamanindian
ID: 16806418
Ok..if u break this up in two lines, does this work? E.g.
---------------------------------------------------------------
var selectedArrayStr="VendorId"+vendorId+"Array";
var selectedArray=eval(selectedArrayStr);
---------------------------------------------------------------

And...what version of Netscape are u using?

Regards
WC
0
 

Author Comment

by:netformx
ID: 16806429
I should support Netscape 7.1, 7.2, 8, Firefox
0
 
LVL 10

Expert Comment

by:iamanindian
ID: 16806441
Hmnn...ur code works fine in FF 1.0.5.

I will check the issue with NN.

Regards
WC

PS: But...did that 2 line idea work?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:netformx
ID: 16806464
no it didn't
0
 
LVL 12

Expert Comment

by:UnexplainedWays
ID: 16807384
Could you try the whole thing?

 eval("var selectedArray = VendorId" + vendorId + "Array");
0
 
LVL 29

Accepted Solution

by:
Pravin Asar earned 2000 total points
ID: 16810370
I tested following code in IE6, FF1.5.0.3 NS8.0.3.3 and Opera 8.52
Check if this works for you. I will catch error and show alert if something else is wrong.


<HTML>
<HEAD>
<TITLE>Evaluate Variable </TITLE>
<STYLE>
</STYLE>
</HEAD>
<BODY>

<script language="javascript">
function handleErr(err)
{
txt="There was an error on this page.\n\n"
txt+="Error: " + err + "\n"
alert(txt)
return true
}
onerror=handleErr;

var VendorId123Array = new Array();  
VendorId123Array[0] = 1;
VendorId123Array[1] = 'TEST';

var vendorId  = 123;
var selectedArray = eval("VendorId"+vendorId+"Array");
if (typeof(selectedArray) != 'object') { alert ('Not an object'); };
document.write (selectedArray);

</script>
</BODY>
</HTML>
0
 
LVL 12

Expert Comment

by:UnexplainedWays
ID: 16813416
Works is  Netscape 8.0.3.3
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question