473,543 Members | 1,903 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IE not grabbing SELECT value

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 CurrentPosition Picks select box in
the resume page
// depending on what one was selected in the LevelOne select box.
for (var i=0;i<document. Resume.CurrentP ositionPicks.le ngth;i++) //
empty the list
{
document.Resume .CurrentPositio nPicks.options. length=0;
}

// LevelOnePicks is the top level select box in the resume form
// CurrentPosition Picks is the dynamically generated select list
var CurrentPosition Picks=document. Resume.CurrentP ositionPicks;
for (var i=0;i<document. Resume.LevelOne Picks.length;i+ +)
{
if (document.Resum e.LevelOnePicks .options[i].selected)
{
var ThisList=eval(T opLevel[i].Name); // get the array name to use
for (var j=0; j < ThisList.length ; j++)
{
CurrentPosition Picks.options[j]=new Option;
CurrentPosition Picks.options[j].text=ThisList[j];
}
}
}
}
Jul 23 '05 #1
6 5977
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 CurrentPosition Picks select box in the resume page
// depending on what one was selected in the LevelOne select box.
for (var i=0;i<document. Resume.CurrentP ositionPicks.le ngth;i++) //
empty the list
{
document.Resume .CurrentPositio nPicks.options. length=0;
}

// LevelOnePicks is the top level select box in the resume form
// CurrentPosition Picks is the dynamically generated select list
var CurrentPosition Picks=document. Resume.CurrentP ositionPicks;
for (var i=0;i<document. Resume.LevelOne Picks.length;i+ +)
{
if (document.Resum e.LevelOnePicks .options[i].selected)
{
var ThisList=eval(T opLevel[i].Name); // get the array name to use
for (var j=0; j < ThisList.length ; j++)
{
CurrentPosition Picks.options[j]=new Option;
CurrentPosition Picks.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 .CurrentPositio nPicks;
for (var i = 0, l = msel.length; i < l; ++i)
{
if ((o = msel.options[i]).selected)
picked.push(o.t ext);
}
alert(
'You chose\n' +
document.Resume .LevelOnePicks. value +
':' +
picked.join(' | ')
);
}

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

Jul 23 '05 #2
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:


I would use a simpler technique:

<script type="text/javascript">
window["night spots"]=["Café Royale","Maxim' s","Rose and Crown"];
cars=["ford","dodge", "buick"];
countries=["USA","UK","Eas t Timor"];

function populateMenuWit hArray(menu,arr ay){
var alen=array.leng th;
menu.options.le ngth=0;
for(var i=0;i<alen;i++) {
menu.options[i]=new Option(array[i],array[i]);
}
}

</script>

<form action="some.ht ml" method="get" name="f">
<select name="a" onchange=
"if(this.select edIndex)
populateMenuWit hArray(this.for m.b,
window[this[this.selectedIn dex].text]);">
<option selected>Select One</option>
<option>cars</option>
<option>countri es</option>
<option>night spots</option>
</select>
<select name="b"></select>
Mick (tested)

snip
Jul 23 '05 #3
Mick White wrote:
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:

I would use a simpler technique:

<script type="text/javascript">
window["night spots"]=["Café Royale","Maxim' s","Rose and Crown"];
cars=["ford","dodge", "buick"];
countries=["USA","UK","Eas t Timor"];

function populateMenuWit hArray(menu,arr ay){
var alen=array.leng th;
menu.options.le ngth=0;
for(var i=0;i<alen;i++) {
menu.options[i]=new Option(array[i],array[i]);
}
}

</script>

<form action="some.ht ml" method="get" name="f">
<select name="a" onchange=
"if(this.select edIndex)
populateMenuWit hArray(this.for m.b,
window[this[this.selectedIn dex].text]);">
<option selected>Select One</option>
<option>cars</option>
<option>countri es</option>
<option>night spots</option>
</select>
<select name="b"></select>
Mick (tested)

snip


Thanks for the quick response - I do like your simpler function. But IE
still only shows the second SELECT box choice.

I'm going to try the suggestion by RobB about looping through the list
boxes.
Jul 23 '05 #4
RobB wrote:
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 CurrentPosition Picks select box in


the resume page
// depending on what one was selected in the LevelOne select box.
for (var i=0;i<document. Resume.CurrentP ositionPicks.le ngth;i++) //
empty the list
{
document.Resume .CurrentPositio nPicks.options. length=0;
}

// LevelOnePicks is the top level select box in the resume form
// CurrentPosition Picks is the dynamically generated select list
var CurrentPosition Picks=document. Resume.CurrentP ositionPicks;
for (var i=0;i<document. Resume.LevelOne Picks.length;i+ +)
{
if (document.Resum e.LevelOnePicks .options[i].selected)
{
var ThisList=eval(T opLevel[i].Name); // get the array name to use
for (var j=0; j < ThisList.length ; j++)
{
CurrentPosition Picks.options[j]=new Option;
CurrentPosition Picks.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 .CurrentPositio nPicks;
for (var i = 0, l = msel.length; i < l; ++i)
{
if ((o = msel.options[i]).selected)
picked.push(o.t ext);
}
alert(
'You chose\n' +
document.Resume .LevelOnePicks. value +
':' +
picked.join(' | ')
);
}

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


Ah, that figures. Thanks for the direction and the sample code.

Jul 23 '05 #5
RobB wrote:
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 CurrentPosition Picks select box in


the resume page
// depending on what one was selected in the LevelOne select box.
for (var i=0;i<document. Resume.CurrentP ositionPicks.le ngth;i++) //
empty the list
{
document.Resume .CurrentPositio nPicks.options. length=0;
}

// LevelOnePicks is the top level select box in the resume form
// CurrentPosition Picks is the dynamically generated select list
var CurrentPosition Picks=document. Resume.CurrentP ositionPicks;
for (var i=0;i<document. Resume.LevelOne Picks.length;i+ +)
{
if (document.Resum e.LevelOnePicks .options[i].selected)
{
var ThisList=eval(T opLevel[i].Name); // get the array name to use
for (var j=0; j < ThisList.length ; j++)
{
CurrentPosition Picks.options[j]=new Option;
CurrentPosition Picks.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 .CurrentPositio nPicks;
for (var i = 0, l = msel.length; i < l; ++i)
{
if ((o = msel.options[i]).selected)
picked.push(o.t ext);
}
alert(
'You chose\n' +
document.Resume .LevelOnePicks. value +
':' +
picked.join(' | ')
);
}

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


This solution worked perfectly (but I changed the order of display).
Thanks again.
Jul 23 '05 #6
Amer Neely wrote:
Mick White wrote:


function populateMenuWit hArray(menu,arr ay){
var alen=array.leng th;
menu.options.le ngth=0;
for(var i=0;i<alen;i++) {
menu.options[i]=new Option(array[i],array[i]);
}
}

</script> snip

Thanks for the quick response - I do like your simpler function. But IE
still only shows the second SELECT box choice.

I'm going to try the suggestion by RobB about looping through the list
boxes.


Works for me, IE 5.2(Mac), FF 1.0(mac), Moz 1.7.3(Mac), Safari 1.03
Mick
Jul 23 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1299
by: InvisibleMan | last post by:
Hi, Thanks for any help in advance... I'm wondering if anyone knows how or has the resource for graabing a users email address without them knowing? Before I hear all the 'Its not ethical' blurb - I know and my use is legitimate... I am build an e-commerce store and as well as grabbing the users IP at point of sale, i think it would be...
0
1166
by: T. | last post by:
How do you assign a value of type OLE BSTR to a C# string as shown by this code snippet. I am getting an 'EXCEPTION_ACCESS_VIOLATION...' runtime error. SQLDMO.SQLServer; SQLDMO.Database db; SQLDMO.QueryResults qrytxt; string msg; string sql = "select * from tblCustomers" string s1; char c1;
4
1383
by: darrel | last post by:
I have a contact form that a person submits to the server. In ASP, you'd make a page, post the form to another page, which would grab the values and do somethign with them. in ASP.NET, it appears that you grab the values directly from the form objects on the postback. Here's our problem:
2
1256
by: Darrel | last post by:
I have a control that transforms an XML file using XSLT. I also want to grab a particular variable out of the XML file. I thought an easy way to do this would be no have the XSLT just find the variable, and write it out as a hidden htmlInputHidden tag. I could then just grab the value of that HTML tag via the codebehind. This does not...
1
1132
by: darrel | last post by:
Is there any way to detect the specific version of an MS Office document when accepting it from an upload? I'm creating a mini-document upload tool for people to manage some MS-office centric documents for public consumption. Ideally, I'd want people to save these files back a few versions for the best accessibility. I was going to simply...
3
2044
by: Bengt Richter | last post by:
Has anyone found a way besides not deriving from dict? Shouldn't there be a way? TIA (need this for what I hope is an improvement on the Larosa/Foord OrderedDict ;-) I guess I can just document that you have to spell it dict(d.items()), but I'd like to hide the internal shenanigans ;-) Regards, Bengt Richter
0
1578
by: .Net Sports | last post by:
I've been looking everywhere, but i can't locate any functions, or articles on the net or my resources, on how to open a file using vb.net, and then grabbing certain parts of the file, and putting it into a useable variable. I know there are functions like Split, Len, Trim, etc., but I have found nothing as far as the sequence for the syntax....
0
929
by: hoderbob | last post by:
I have written a printer tracking and user validation application to control color printing abuse at my office. I have one small problem. The spooled print job does not report copies. For example if I print a one page document, and select 100 copies in the windows printer dialog box, (like most of our abusers do), the spooler reports one...
29
3111
by: Amer Neely | last post by:
I've got a dynamically built form with checkboxes for each element ( a list of file names in a directory). I need to grab only those checkboxes that are checked, so I can then delete those files. Does each checkbox name have to be unique? I was hoping to just group them under one name, and select from that array. PHP is not my native...
0
7411
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7354
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5282
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4898
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3394
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
643
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.