• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

eval in Netscape does not work properly

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
netformx
Asked:
netformx
  • 2
  • 2
  • 2
  • +1
1 Solution
 
iamanindianCommented:
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
 
netformxAuthor Commented:
I should support Netscape 7.1, 7.2, 8, Firefox
0
 
iamanindianCommented:
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
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
netformxAuthor Commented:
no it didn't
0
 
UnexplainedWaysCommented:
Could you try the whole thing?

 eval("var selectedArray = VendorId" + vendorId + "Array");
0
 
Pravin AsarPrincipal Systems EngineerCommented:
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
 
UnexplainedWaysCommented:
Works is  Netscape 8.0.3.3
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now