Hello,
I got an array which I iterate over and try to create a variable.
The name of the variable is variable and comes from the array. So I am using eval (this code will only be used on my local computer) to create the variables. Weird enough I can create a variable and add plain text to the contents of it. But whenever I try to set a variable variable I get nothing.
I'm also using Prototype to easily walk the DOM.
var arr_entries = some_DOM_element;
arr_entries_array = new Array();
arr_entries_array[0] = new Array();
arr_entries_array[0][0] = 'name_dd';
arr_entries_array[0][1] = arr_entries.next(13).down().next(1).innerHTML;
arr_entries_array[1] = new Array();
arr_entries_array[1][0] = 'name_pl';
arr_entries_array[1][1] = arr_entries.next(14).down().next().innerHTML;
arr_entries_array[2] = new Array();
arr_entries_array[2][0] = 'name_pm';
arr_entries_array[2][1] = arr_entries.next(15).down().next().innerHTML;
arr_entries_array[3] = new Array();
arr_entries_array[3][0] = 'name_hd';
arr_entries_array[3][1] = arr_entries.next(17).down().next().innerHTML;
arr_entries_array[4] = new Array();
arr_entries_array[4][0] = 'name_sr';
arr_entries_array[4][1] = arr_entries.next(16).down().next().innerHTML;
for(e = 0; e < arr_entries_array.length; e++)
{
eval('var arr_entry_' + arr_entries_array[e][0] + ';');
eval('arr_entry_' + arr_entries_array[e][0] + ' = \'' + arr_entries_array[e][1] + '\';');
}
I can alert(arr_entries_array[e][1]
) just fine. I can also replace it with plain text, alert the variable afterwards and it will work.
The second eval line is where it goes wrong, any comments?