473,325 Members | 2,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Selecting all items in a multiple select: inconsistency with Internet Explorer

Hi

I was wondering if anyone else had had this problem before (can't find
anything on the web about it).

I have three select elements (list boxes - from here on I'll refer to
them as 'the list boxes'). Users can add and remove items from the
list boxes.

When the users are adding and removing items, the list boxes are single
selection only. However, when the form is submitted, I want ALL items
to be submitted. So I have written the following script,which ensures
that all elements in each box are selected when the user submits the
form. It works by programatically setting the list boxes to multiple,
and then selecting the controls in them:

function selectAllInLists()
{
var controlArray = new Array();
controlArray[0] = "bTelephone";
controlArray[1] = "bEmail";
controlArray[2] = "bWebsite";

for(var i=0;i<controlArray.length;i++)
{
var listWeb = document.getElementById(controlArray[i]);
listWeb.multiple = true;

for(var j=0;j<listWeb.length;j++)
{
listWeb[j].selected = true;
}
}
}

This works fine with Firefox, and most of the time in Internet
Explorer. However, if the user wants to update an existing record, and
the list boxes have more than one element (each), and the user makes no
change to the list boxes (doesn't touch them), THEN only the last item
in each list box is passed when the form is submitted. Perplexing!!
I've tried a number of hacks, such as programmatically selecting the
list box when entering the page, and adding and deleting one
programmatically. No luck.

Any pointers would be greatly appreciated!

Cheers

James

Sep 6 '05 #1
3 2381
ja*********@canberra.edu.au wrote:
Hi

I was wondering if anyone else had had this problem before (can't find
anything on the web about it).

I have three select elements (list boxes - from here on I'll refer to
them as 'the list boxes'). Users can add and remove items from the
list boxes.

When the users are adding and removing items, the list boxes are single
selection only. However, when the form is submitted, I want ALL items
to be submitted. So I have written the following script,which ensures
that all elements in each box are selected when the user submits the
form. It works by programatically setting the list boxes to multiple,
and then selecting the controls in them:

function selectAllInLists()
{
var controlArray = new Array();
controlArray[0] = "bTelephone";
controlArray[1] = "bEmail";
controlArray[2] = "bWebsite";
This could be written as:

var controlArray = [
"bTelephone",
"bEmail",
"bWebsite"
];

for(var i=0;i<controlArray.length;i++)
{
var listWeb = document.getElementById(controlArray[i]);
listWeb.multiple = true;

for(var j=0;j<listWeb.length;j++)
{
listWeb[j].selected = true;
}
}
}

This works fine with Firefox, and most of the time in Internet
Explorer. However, if the user wants to update an existing record, and
the list boxes have more than one element (each), and the user makes no
change to the list boxes (doesn't touch them), THEN only the last item
in each list box is passed when the form is submitted. Perplexing!!
I've tried a number of hacks, such as programmatically selecting the
list box when entering the page, and adding and deleting one
programmatically. No luck.

Any pointers would be greatly appreciated!


Have you considered writing the values to a hidden input? Then ignore
whatever values you get from the selects. You can format the value of
the hidden input to whatever suits your server parser.

If JavaScript is not available on the client you will get junk, but
since your form is already dependent on JavaScript perhaps that's not an
issue for you.
--
Rob
Sep 6 '05 #2
RobG wrote:
Have you considered writing the values to a hidden input? Then ignore
whatever values you get from the selects.


Like I've done here, in a library that you might be able to just plug in:
http://www.javascripttoolbox.com/optiontransfer/

Hope that helps!

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Sep 7 '05 #3
Thanks Rob, I did as you suggested, and it works. Still a real pain
though - I wonder if that is an identified bug?

Sep 7 '05 #4

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

Similar topics

0
by: Mike | last post by:
I have just installed Visual Studio .NET and all necessary Windows Updates. I can open my project in the IDE without any problems and can run it without any problems. My PC's OS is Windows 2000...
6
by: Stephen Cook | last post by:
Having worked through the problems around enabling the document function using an XmlUrlResolver I started work on building a useful class to hide the intricacies. Trying to generalise the process...
4
by: Ron | last post by:
I've got a listbox that holds a list of groups. Users can select a group, hit the remove button and the group should be removed from the listbox. The only problem is that no matter which group you...
1
by: sneha123 | last post by:
There will be some 20 questions and for each question there will be 4 choices.what i want to do is to select multiple answers by clicking the checkbox. i m using asp.net,vb.net pls help me we...
1
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been...
2
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
1
by: c35tar1 | last post by:
I have a ListView within a dialog. In code the groups are created and items added. Display is 100% correct. The problem is with using Shift to select multiple items in the list. - If you...
1
by: KrazyKasper | last post by:
Access 2003 – Multi-Column List Box – Select Multiple Items I have a multi-column (3 columns) list box that works well to select one set of records or all sets of records (based on the first field...
1
by: tomaz | last post by:
Hi I have a website with multiple included js-files, included css-files... There is a virtual keyboard programmed (for touchscreen use) the moment I click on the keyboard icon to open the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.