[thelist] Using variables in DOM object names

Ryan Rushton web at ryanrushton.com
Wed Jul 13 09:43:54 CDT 2005


> The original code indicates the form fieldnames are in name
> attributes, not id. As an alternative, not saying a better approach
> but probably more backward-compatible:
>
>         var fieldnames = new Array("firstname","lastname","city")
>         for (var i=0; i<fieldnames.length; i++)
>         {
window.opener.document.studentReg.elements[fieldnames[i]].value=document.studentSelect.elements[fieldnames[i]].value;
>         }

Thanks Joe.  I worked out a number of different solutions based on advice
posted in this thread, but yours ultimately was the one I used.  Much
thanks to you and everyone else for the help.



More information about the thelist mailing list