Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Message from discussion IE not grabbing SELECT value
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
RobB  
View profile  
 More options May 5 2005, 1:57 am
Newsgroups: comp.lang.javascript
From: "RobB" <fernd...@hotmail.com>
Date: 4 May 2005 08:57:36 -0700
Local: Thurs, May 5 2005 1:57 am
Subject: Re: IE not grabbing SELECT value

Amer Neely wrote:
> I have a page showing dynamic generation of a SELECT box using
> JavaScript. See http://www.softouch.on.ca/dynamic.html.

> Using Mozilla et al, choosing an option from both lists will result
in
> the correct response when 'Show Me' is clicked. But IE only shows the
> result from the first SELECT box. Any ideas why / how to fix this?

> The function I'm using:
> function updateList(what)
> {
>    // This dynamically populates the CurrentPositionPicks select box in
> the resume page
>    // depending on what one was selected in the LevelOne select box.
>    for (var i=0;i<document.Resume.CurrentPositionPicks.length;i++) //
> empty the list
>    {
>            document.Resume.CurrentPositionPicks.options.length=0;
>    }

>    // LevelOnePicks is the top level select box in the resume form
>    // CurrentPositionPicks is the dynamically generated select list
>    var CurrentPositionPicks=document.Resume.CurrentPositionPicks;
>    for (var i=0;i<document.Resume.LevelOnePicks.length;i++)
>    {
>            if (document.Resume.LevelOnePicks.options[i].selected)
>            {
>                    var ThisList=eval(TopLevel[i].Name); // get the array name to use
>                    for (var j=0; j < ThisList.length; j++)
>                    {
>                            CurrentPositionPicks.options[j]=new Option;
>                            CurrentPositionPicks.options[j].text=ThisList[j];
>                    }
>            }
>    }
> }

The two browsers handle multiple selects differently. To get selected
option values/texts cross-browser, you need to loop the options and
examine them. In addition, your updateList() function isn't setting
option values, just displayed text. Some browsers will substitute the
latter for the former but, don't rely on it...set both.

function Output()
{
 var o,
 picked = [],
 msel = document.Resume.CurrentPositionPicks;
 for (var i = 0, l = msel.length; i < l; ++i)
 {
  if ((o = msel.options[i]).selected)
   picked.push(o.text);
 }
 alert(
  'You chose\n' +
  document.Resume.LevelOnePicks.value +
  ':' +
  picked.join(' | ')
 );

}

Matt Kruse will now plug his script. #:=D

    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google