[Javascript] Adding an item to a select list from another window
David Lovering
dlovering at gazos.com
Thu Sep 25 10:51:02 CDT 2003
Great, but that's not how you do it -- at least according to the W3C spec.
var myElementIndex = eval('aValue[' + i + ']'); // may be unnecessary, as
I'm not sure how this variable is set in your example
var openerObject = window.opener.document.forms[0].elements[myElementIndex];
// this points to the select object you want to diddle with
var numItems = openerObject.length; // number of entries already in
pull-down
openerObject.options[numItems] = new Option("myText", "myValue", false,
false);
Obviously, "myText", and "myValue" can be anything appropriate.
The last two booleans have to do with whether the item is selected, and/or
the default selection.
If your JavaScript environment is at all shaky you can put the right-hand
side of the logical assignments into "evals", although it usually works
without.
-- Dave Lovering
----- Original Message -----
From: "Robert Pollard" <rpollard at apple.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Thursday, September 25, 2003 8:27 AM
Subject: Re: [Javascript] Adding an item to a select list from another
window
> The first one updates the Select list's text and the other updates the
> Select list's value.
>
> Thanks,
>
> Robert
>
> On Thursday, September 25, 2003, at 06:07 AM, Chris Tifer wrote:
>
> >> It's good up until here. This next line causes Explorer to
> >> unexpectedly quit.
> >>
> >> window.opener.document.forms[0].elements[aValue[i]].options[j].options
> >> [j
> >> ] = vFields;
> >
> >
> > I'm not particularly sure what you're doing here but what why are
> > there 2
> > options in a row?
> >
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
More information about the Javascript
mailing list