[thelist] Using variables in DOM object names

VOLKAN ÖZÇELİK volkan.ozcelik at gmail.com
Wed Jul 13 03:40:01 CDT 2005


Ryan,

There is a syntax error in your eval.

var objFrom = eval("opener.formOne."+fieldnames[i]);
var objTo = eval("opener.formTwo."+fieldnames[i]);
objTo.value = objFrom.value;

should do the trick. Though I have not tested.

You had better use a js debugger imho. 

Venkman is a good debugger for mozilla-based browsers. for msie you
may use microsoft script debugger.

HTH,
Volkan.



On 7/13/05, Ryan Rushton <web at ryanrushton.com> wrote:
> At 11:13 PM 7/12/2005, you wrote:
> > > Because there are many form fields to set, I would like to place them in
> > > an array and loop over the array, but I don't know how to properly refer
> > > to the objects when they have a variable within their name.  Here is my
> > > NON-working code:
> > >
> >
> >How about using globally used document.getElementById (which is also
> >the standard way of doing it) ?
> >
> >imho, you are over-complicating the problem.
> >Besides imho, your code should work. if I don't miss something.
> >Can you give an URL to check?
> 
> It's been awhile since I did much Javscript and I totally forgot about
> getElementById.  No less, I still can't seem to make it work, even with
> getElementById.  I have posted a simplified version at
> http://www.ryanrushton.com/demos/master.html
> --
> 
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
> 
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>


More information about the thelist mailing list