[Javascript] adding Option to an opener.form.select

Terry bader at tcbader.com
Tue Mar 25 10:16:35 CST 2003


thanks...  gives me some ideas...  time to play...

~ Terry
757 581-5981
AIM/Yahoo: lv2bounce


----- Original Message -----
From: "David T. Lovering" <dlovering at gazos.com>
To: "[JavaScript List]" <javascript at LaTech.edu>
Sent: Tuesday, March 25, 2003 11:15 AM
Subject: Re: [Javascript] adding Option to an opener.form.select


>
> Well, I've used this between remotes and the parent window (thereby making
all the inheritance Nazis jump up and down) by simply prefacing the
directive with 'window.opener'.  Obviously, if you have multiple forms
you'll have to use more inventive means
> of addressing them, such as 'window.opener.document.forms["myForm2"]' or
whatever.  It will get even more complicated if you have multiple forms AND
multiple frames, for you'll have to address the frame first before you can
hook on to the form.
>
> One way to avoid exercising the inheritance Nazis quite so much is to
create a function native to the remote/parent window which adds the option
you need.  Then you can play the 'remote' game --
>
> window.opener.document.forms["myForm2].addNewOption("nifty");
>
> where addNewOption is a function defined within the same page you are
trying to change.  Obviously, if you are working from the parent window to a
child window, all you have to do is dispense with the 'opener' directive,
and use
>
> winID.document.forms["myForm2"].addNewOption("nifty");
>
> where winID is the window identifier created when the child window was
spawned originally.
>
>   Many variations are possible, and the pitfalls you experience will
depend on the architecture of how your frames, forms, and child windows are
linked.  I won't pretend that this will solve all your problems
straight-away, but it may give you some
> notions.  If you want to poke me again with a more explicit architectural
relationship of how your various bits fit together, I'll be glad to look
into it.
>
>   [Depending on how tightly meshed your code is, you may have to
dereference to 'parent' or 'top' in order to get the various bits to see
each other].
>
>   -- Dave Lovering
>
> Terry wrote:
> >
> > thanks, but using the forms[x] is out of the question as other forms
maybe
> > added in areas previous to the this dynamically...  and your example
> > addresses a select in the current document and not the opener in which i
am
> > having the problems...
> >
> > and as for the other info, i know what the function definition is for
> > option() and how to develop for my audience...  what i need is a second
look
> > at previous code to see if i missed something...  or to see if this is a
> > know bug/problem...
> >
> > i tried adding .options[length] to the intialization of the new index
but
> > that still crashed it... even removed the 3rd and 4th arguments in the
new
> > option() declaration... still the same... everything so far leads to a
> > crashed browser (IE)...
> >
> > the problem i think is browser based when adding options to select
objects
> > in the opener,  everytime it tries to set something in the opener select
for
> > which an index doesnt not exist it crashes...  however, when just
updating a
> > current index value it works fine, but that means one of my options is
> > overridden....
> >
> > so i am now working on a work-around....  was hoping someone had more
> > constructive data on this problem with a select in the opener...
> >
> > and as for your "ranting", i would leave that to the other lists to
> > debate...
> >
> > thanks....
> >
> > ~ Terry
> > 757 581-5981
> > AIM/Yahoo: lv2bounce
> >
> > ----- Original Message -----
> > From: "David T. Lovering" <dlovering at gazos.com>
> > To: "[JavaScript List]" <javascript at LaTech.edu>
> > Sent: Tuesday, March 25, 2003 10:34 AM
> > Subject: Re: [Javascript] adding Option to an opener.form.select
> >
> > >
> > > Ugh!  Cold-Fusion (even the latest and greatest version) is a poor
> > substitute for good solid PHP, Java, and JavaScript coding.  Its
features
> > are chaotic, non-orthogonal, and integrate very poorly with other
packages,
> > and have all sorts of inheritance
> > > issues which will drive you mad eventually.  [And let us not forget
that
> > it is God-awful slow, has huge latency problems, and sucks screen and
CPU
> > resources]. The only people who like it are newbies who think they only
have
> > to learn one "language" to make
> > > everything they want done happen without any downsides.
> > > Enough ranting.
> > >
> > > The method I use for adding to a pre-existing select widget is as
> > follows --
> > >
> > >   var myMenu = document.forms[0].mySelect;
> > >   myMenu.options[myMenu.length] = new Option("bogus", "bogus-value");
> > >
> > > Obviously, you can insert the other two Option parameters if you wish
[the
> > third controls the default selection, and the fourth determines whether
this
> > item is selected for the moment], but I usually leave that to my 'init'
> > routine to work out.
> > >
> > > Although the DOM model certainly encourages you to believe that the
> > universal constructor assignments are 100% viable, I've had problems
with
> > them, particularly in computing environments with diverse browsers,
OS's,
> > and such like.  You are welcome to try
> > > them of course (and many are very useful), but be sure to vet them for
all
> > the platforms you expect to have exercising your code.
> > >
> > > -- Dave Lovering
> > >
> > >
> > >
> > >
> > > Terry wrote:
> > > code
> > > -------------------------------------------
> > > newOption = new Option(optTxt, optVal, 0, 1);
> > >
> >
opener.#attributes.formName#.#attributes.elem#[opener.#attributes.formName#.
> > #attributes.elem#.length] = newOption;
> > >
> > >
> > > ok, able to read values from the opener.form.select using the same
syntax
> > as above but i cannot seem to add a new option...
> > >
> > > btw, the ## are CF variables, just assume that attributes.formName is
the
> > name of the form from opener and attributes.elem is the name of the
select
> > object......
> > >
> > > comments??
> > >
> > >
> > > ~ Terry
> > > 757 581-5981
> > > AIM/Yahoo: lv2bounce
> > > _______________________________________________
> > > 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
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>




More information about the Javascript mailing list