Filling form fields using javascript

by Reywob(at)aol.com

 Date:  Wed, 22 Aug 2001 15:01:08 EDT
 To:  hwg-languages(at)hwg.org
  todo: View Thread, Original
Hi,

I have the following code, which is supposed to take some values from a PHP 
script and fill the corresponding form fields with data from an address book 
( the addresses are selected in a popup window, and the code below is to 
populate the fields in the main window).

The problem is that the form fields are named to[0], to_email[0]; to[1], 
to_email[1] and so on, and the [ and ] are causing the javascript to produce 
errors.

How can I get around this problem?  I cannnot change the form field names, so 
have to find some other way of correcting it.

Thanks,
Peter.
___________ THE CODE _____________
if(window.opener.document.sc_form.to[<?php echo $i; ?>])
      {window.opener.document.sc_form.to[<?php echo $i; ?>].value="<?php echo 
($db->f("name")); ?>"};
if(window.opener.document.sc_form.to_email[<?php echo $i; ?>])
      {window.opener.document.sc_form.to_email[<?php echo $i; 
?>].value="<?php echo ($db->f("email")); ?>"};

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA