@Jeff_MottMar 24.2005 — #Though you'd be far better off using array/object indexes to accomplish this. Avoid using eval whenever possible.var apple = {};
var num = 1; apple[num] = "whatever"; /* sets apple[1] */
@js_prof_consMar 27.2005 — #[code=html] <script> var num=1 window["apple"+num]="hi" alert(apple1)//returns hi </script> [/code][/QUOTE]You brought it back from the dead, but good job switching to the window[] object!
@fredmvMar 28.2005 — #Though you'd be far better off using array/object indexes to accomplish this. Avoid using eval whenever possible.var apple = {};
var num = 1; apple[num] = "whatever"; /* sets apple[1] */[/QUOTE]This is the most desirable solution. And, you should never use [font=courier]eval[/font] because it uses a ton more resources than if you were not to (it, essentially, creates another instance of the JavaScript interpreter -- [i]very[/i] costly).
@js_prof_consMar 28.2005 — #Yes. Ultimater figured that out in another thread an made a revision to his code. Neithe rof us claimed it to be the better code between his and Jeff's, just between his two versions. No intention for confusion.
EDIT: However, despite Jeff's code being better consentually between us, it is Ultimater's which actually answers the original poster's needs to the fullest extent.