Currently, I have an array that I am looping through in order to create variables.
The variable names are derived from the array itself and I am using eval (only on my local machine) to achieve this. Interestingly, I can successfully create a variable and assign plain text to it. However, when attempting to set a variable within another variable, nothing happens.
In addition, I am utilizing Prototype for DOM traversal ease.
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 successfully alert (arr_entries_array[e][1]
). I can even replace it with plain text, alert the variable later, and it functions as expected.
The issue arises in the second eval line, any suggestions or insights?