Re: Fwd: RE: Netscape 7 changing a dropdown menu

by Robin Liston <rliston(at)cox.net>

 Date:  Thu, 19 Sep 2002 19:56:13 -0700
 To:  hwg-languages(at)hwg.org
 In-Reply-To: 
  todo: View Thread, Original
Thanks for you help, you got me 99% there.

I just had to change a few things to make it work:
var list = "opener.document.form1.RecStateDB"; to  var list = 
opener.document.form1.RecStateDB;
index = i;  } to index = i;  break; }
and if (x == index){ list.options[x].selected = true; } to  if (x == 
index){ list.options[x].selected = true; break; }



At 07:46 PM 09/19/2002 -0700, you wrote:

>--- "Gronitz, Dan" <gronitz(at)shell.core.com> wrote:
> > From: "Gronitz, Dan" <gronitz(at)shell.core.com>
> > To: "Robin Liston" <rliston(at)cox.net>
> > Subject: RE: Netscape 7 changing a dropdown menu
> > Date: Thu, 19 Sep 2002 04:06:31 -0500
> >
> >       The line of code that you have listed doesn't
> > actually select the proper
> > option from the drop down menu (At least not on my
> > end), it changes the
> > "text value" of your currently selected menu list
> > item.
> >
> >       When I use IE5.5 it changes the - Please Choose -
> > to CA so CA is the first
> > value in the drop down menu but CA is also still a
> > choice later in the menu
> > as well. In Netscape 7 it makes the width of the
> > drop down menu smaller but
> > won't actually change the - Please Choose - value (I
> > think this may have to
> > do with the fact that Netscape might not allow write
> > permission on the "text
> > value" of an Option).
> >
> >       As far as I know - so if someone else knows a way
> > to do this otherwise
> > PLEASE let me know! - you have to run through your
> > list of options and set
> > the one (or ones in a multiple select list) you want
> > selected to true and
> > the rest to false. Since you're referencing by the
> > "text" value I've had to
> > add a little more code than if it were just by
> > index.
> >
> >       Remove the line of code that you have in the
> > u_address_test.htm file --
> >
> >
>opener.document.form1.RecStateDB.options[opener.document.form1.RecStateDB.se
> > lectedIndex].text = "CA";
> >
> >       and replace with the following:
> >
> > var list = "opener.document.form1.RecStateDB";
> >
> > for (var i = 0; i <= list.options.length; i++){
> >  if(list.options[i].text == "CA"){
> >   index = i;
> >  }
> > }
> >
> > for (var x = 0; x <= list.options.length; x++ ){
> >  if (x == index){ list.options[x].selected = true; }
> >  else{ list.options[x].selected = false; }
> > }
> >
> >
> >       This worked on IE5.5, Netscape 7 and 4.5. I'm sorry
> > that the code isn't
> > very pretty or compact but I wasn't sure exactly
> > what you were planning to
> > do with the code. Also I only added the var "list"
> > so I wasn't typing so
> > much *grin* feel free to expand it if you want to.
> > The rest of the code can
> > be modified and made more "compact" by possibly
> > omitting some things but I
> > left it the way I first got it to work. I did this
> > just incase you wanted to
> > use the code for something other/more than you have
> > it on the page now. I
> > hope it helps!
> >
> >       -Dan
> >
> >
> > ------
> > http://www.di-wi.com
> > gronitz(at)di-wi.com
> > gronitz(at)shell.core.com

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