[Javascript] adding Option to an opener.form.select - Work Around

Chris Tifer christ at saeweb.com
Tue Mar 25 12:15:49 CST 2003


Includes are invaluable - whether it's server- or client-side. I use
.js files a whole lot. I tend to separate mine by their function, like
all my window opening routines are defined in one file, etc.

Chris Tifer
http://emailajoke.com

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


>
> I got burned by this so often I finally capitulated and put all my common
routines in a library which I load as a matter of course into every window I
launch (parent or remote), so I never have to wonder whether my code is
available for use.  Mind you,
> this ups the latency on the initial load by a smidgen, but JavaScript is
so much faster than Java (to load and translate from byte code) that it is
almost negligible by comparison.
>
> Glad to have been of help.
>
> -- Dave
>
> this works for what i want, thanks.....
>
>
> pop-up window code:
> -------------------------------------------
>   opener.#attributes.formName#.optTxt.value = optTxt;
>   opener.#attributes.formName#.optVal.value = optVal;
>   opener.addSelect(optTxt,optVal);
>
> opener window code:
> ------------------------------------------
>  function addSelect(newTxt, newVal) {
>   newOption = new Option(newTxt, newVal, false, false);
>
document.#formName#.#elemName#.options[document.#formName#.#elemName#.length
] = newOption;
>  }
>
> same damn code really...  i just moved the code that adds the new index to
the parent page...
>
> thanks again....
>
> ~ Terry
> 757 581-5981
> AIM/Yahoo: lv2bounce
>
>
> ----- Original Message -----
> From: "Terry" <bader at tcbader.com>
> To: "[JavaScript List]" <javascript at LaTech.edu>
> Sent: Tuesday, March 25, 2003 11:16 AM
> Subject: Re: [Javascript] adding Option to an opener.form.select
>
>
> > 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
> > >
> >
> >
> > _______________________________________________
> > 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