473,394 Members | 1,285 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,394 software developers and data experts.

multiple <select> + IE: selection invisible

hi,

I have a php-Script which gets passed a Boat-ID and this is used to
mark an element in a <select> as the default:
<select name="boote[]" multiple="multiple" size="5">
<option value='43'>Aisha</option>
<option value='40'>Amsterdam</option>
<option value='55'>Asmaa</option>
<option value='20'>Beau Rivage</option>
<option value='48'>Blue Perl</option>
<option value='49'>Blue Planet 1</option>
<option value='37'>Capt. Moro</option>
<option value='41'>Coral Queen</option>
<option value='2' selected='selected'>Diamond-Heaven</option>
<option value='10'>Discovery</option>
<option value='21'>Dive One</option>
</select>

The problem is that this is a multiple selection <select> and while
with the above code, "Diamond-Heaven" is selected, it is
not visible (not in the scrolled window).

How can I make it behave somewhat like Mozilla (selected item is in
visible window by default)?

Maybe using javascript?

thanks,

--
Felix Natter
Jul 20 '05 #1
7 7869

"Felix Natter" <fe**********@ldc.de> wrote in message
news:m3************@werkstatt4.ldc...
hi,

I have a php-Script which gets passed a Boat-ID and this is used to
mark an element in a <select> as the default:
<select name="boote[]" multiple="multiple" size="5">
<option value='43'>Aisha</option>
<option value='40'>Amsterdam</option>
<option value='55'>Asmaa</option>
<option value='20'>Beau Rivage</option>
<option value='48'>Blue Perl</option>
<option value='49'>Blue Planet 1</option>
<option value='37'>Capt. Moro</option>
<option value='41'>Coral Queen</option>
<option value='2' selected='selected'>Diamond-Heaven</option>
<option value='10'>Discovery</option>
<option value='21'>Dive One</option>
</select>

The problem is that this is a multiple selection <select> and while
with the above code, "Diamond-Heaven" is selected, it is
not visible (not in the scrolled window).

How can I make it behave somewhat like Mozilla (selected item is in
visible window by default)?


If more than one item happens to be selected, how would you propose to
arrange for all of them to appear in the visible portion of the list at the
same time? The selected items might even include the first and last items in
the list. You can see from considering this that it's not practical for
multi-selection lists to behave in the manner you're used to from
single-selection lists.

Jul 20 '05 #2
"Harlan Messinger" <h.*********@comcast.net> writes:
"Felix Natter" <fe**********@ldc.de> wrote in message
news:m3************@werkstatt4.ldc...
hi,

I have a php-Script which gets passed a Boat-ID and this is used to
mark an element in a <select> as the default:
<select name="boote[]" multiple="multiple" size="5">
<option value='43'>Aisha</option>
<option value='40'>Amsterdam</option>
<option value='55'>Asmaa</option>
<option value='20'>Beau Rivage</option>
<option value='48'>Blue Perl</option>
<option value='49'>Blue Planet 1</option>
<option value='37'>Capt. Moro</option>
<option value='41'>Coral Queen</option>
<option value='2' selected='selected'>Diamond-Heaven</option>
<option value='10'>Discovery</option>
<option value='21'>Dive One</option>
</select>

The problem is that this is a multiple selection <select> and while
with the above code, "Diamond-Heaven" is selected, it is
not visible (not in the scrolled window).

How can I make it behave somewhat like Mozilla (selected item is in
visible window by default)?


If more than one item happens to be selected, how would you propose to
arrange for all of them to appear in the visible portion of the list at the
same time? The selected items might even include the first and last items in
the list. You can see from considering this that it's not practical for
multi-selection lists to behave in the manner you're used to from
single-selection lists.


It is practical for the special case that only one item is selected!
(even when two items are selected it can just jump to the first one,
but I need only the "one element" special case)

Consider: the code above appears in a php script query_boat.php which
accepts a parameter 'boat'. This parameter (value 2 in example above)
specifies which boat is pre-selected. Now the user is on the
description page for the boat "Diamond-Heaven" and clicks on the link
"send query for this boat" (query_boat.php?boat=2) => only one
selection!

Now the user will be confused if he/she does not find that
"Diamond-Heaven" is preselected. So maybe I could read the current
selection and scroll to the appropriate position using javascript?

thanks,

--
Felix Natter
Jul 20 '05 #3
"Felix Natter" <fe**********@ldc.de> a écrit dans le message de
news:m3************@werkstatt4.ldc
I have a php-Script which gets passed a Boat-ID and this is used to
mark an element in a <select> as the default:
<select name="boote[]" multiple="multiple" size="5">
<option value='43'>Aisha</option>
<option value='40'>Amsterdam</option>
<option value='55'>Asmaa</option>
<option value='20'>Beau Rivage</option>
<option value='48'>Blue Perl</option>
<option value='49'>Blue Planet 1</option>
<option value='37'>Capt. Moro</option>
<option value='41'>Coral Queen</option>
<option value='2' selected='selected'>Diamond-Heaven</option>
<option value='10'>Discovery</option>
<option value='21'>Dive One</option>
</select>

The problem is that this is a multiple selection <select> and while
with the above code, "Diamond-Heaven" is selected, it is
not visible (not in the scrolled window).

How can I make it behave somewhat like Mozilla (selected item is in
visible window by default)?


If the order of the option elements are not important, maybe your PHP script
could send the selected elements first ? Something like :

<select name="boote[]" multiple="multiple" size="5">
<option value='2' selected='selected'>Diamond-Heaven</option>
<option value='43'>Aisha</option>
<option value='40'>Amsterdam</option>
<option value='55'>Asmaa</option>
<option value='20'>Beau Rivage</option>
<option value='48'>Blue Perl</option>
<option value='49'>Blue Planet 1</option>
<option value='37'>Capt. Moro</option>
<option value='41'>Coral Queen</option>
<option value='10'>Discovery</option>
<option value='21'>Dive One</option>
</select>

Jul 20 '05 #4
"Felix Natter" <fe**********@ldc.de> wrote:

[ SELECT ]
Now the user will be confused if he/she does not find that
"Diamond-Heaven" is preselected. So maybe I could read the current
selection and scroll to the appropriate position using javascript?


You could try something simple like +-:

onload = function() {
var SelectObject = document.formName.elements["boote[]"];
SelectObject.selectedIndex = SelectObject.selectedIndex;
}
WD
Jul 20 '05 #5
"Pierre Goiffon" <pg******@nowhere.invalid> writes:
"Felix Natter" <fe**********@ldc.de> a écrit dans le message de
news:m3************@werkstatt4.ldc
I have a php-Script which gets passed a Boat-ID and this is used to
mark an element in a <select> as the default:
<select name="boote[]" multiple="multiple" size="5">
<option value='43'>Aisha</option>
<option value='40'>Amsterdam</option>
<option value='55'>Asmaa</option>
<option value='20'>Beau Rivage</option>
<option value='48'>Blue Perl</option>
<option value='49'>Blue Planet 1</option>
<option value='37'>Capt. Moro</option>
<option value='41'>Coral Queen</option>
<option value='2' selected='selected'>Diamond-Heaven</option>
<option value='10'>Discovery</option>
<option value='21'>Dive One</option>
</select>

The problem is that this is a multiple selection <select> and while
with the above code, "Diamond-Heaven" is selected, it is
not visible (not in the scrolled window).

How can I make it behave somewhat like Mozilla (selected item is in
visible window by default)?


If the order of the option elements are not important, maybe your PHP script
could send the selected elements first ? Something like :

<select name="boote[]" multiple="multiple" size="5">
<option value='2' selected='selected'>Diamond-Heaven</option>
<option value='43'>Aisha</option>
<option value='40'>Amsterdam</option>
<option value='55'>Asmaa</option>
<option value='20'>Beau Rivage</option>
<option value='48'>Blue Perl</option>
<option value='49'>Blue Planet 1</option>
<option value='37'>Capt. Moro</option>
<option value='41'>Coral Queen</option>
<option value='10'>Discovery</option>
<option value='21'>Dive One</option>
</select>


Thanks! I came to that conclusion as well. The order is alphabetic,
but I will just move the selected items to the top (maybe with
a "-----" separator).

--
Felix Natter
Jul 20 '05 #6
"Warden Dave" <wa*********@web.de> writes:
"Felix Natter" <fe**********@ldc.de> wrote:

[ SELECT ]
Now the user will be confused if he/she does not find that
"Diamond-Heaven" is preselected. So maybe I could read the current
selection and scroll to the appropriate position using javascript?


You could try something simple like +-:

onload = function() {
var SelectObject = document.formName.elements["boote[]"];
SelectObject.selectedIndex = SelectObject.selectedIndex;
}


this works, thanks! well, almost: if multiple items are selected
(which may happen the second time the page is loaded i.e. when the
user selects another item via Ctrl-click and submits but the form does
not validate) then selectedIndex only returns the first Index and so
all other selections will get lost.

Is there a way (must be compatible with as many browsers as possible)
to get the indices of *all* selected items? If there's no clean solution
I can just use the solution proposed by Pierre Goiffon in this thread.

thanks a lot,

--
Felix Natter
Jul 20 '05 #7
"Felix Natter" <fe**********@ldc.de> wrote:
"Warden Dave" <wa*********@web.de> writes:
You could try something simple like +-:

onload = function() {
var SelectObject = document.formName.elements["boote[]"];
SelectObject.selectedIndex = SelectObject.selectedIndex;
}

this works, thanks! well, almost: if multiple items are selected
(which may happen the second time the page is loaded i.e. when the
user selects another item via Ctrl-click and submits but the form does
not validate) then selectedIndex only returns the first Index and so
all other selections will get lost.


In that case... try something else ;), e.g.:

onload = function() {
var SelectObject = document.theForm.elements["boote[]"];
for (var i=SelectObject.options.length-1; i>=0; i--)
SelectObject.options[i].selected = SelectObject.options[i].selected;
}
WD
Jul 20 '05 #8

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

Similar topics

3
by: gekoblu | last post by:
Hi!, I want to fix via javascript the combo width to a fix value. I'd like to implement a kind of ALT / TITLE function to show the entire option when the text is longer than the combo width......
7
by: | last post by:
I can't get IE 6 to read the values in my <SELECT..> data entry fields. Netscape 7 and Opera see them, and IE will pass the values to the database, but the javascript validation script gets a null...
1
by: Russell Campbell | last post by:
I have a script that I use with no problems when the Size attribute of the Select tag is set to more than one (I have it set to 5, to be specific). But when I drop it to 1 to create a popup, the...
6
by: Omar | last post by:
Hi, In a JSP I have the next: .... codigo = "<select name='" + nombre + "'>\n<option selected value='default'>Escoge</option><option value='todos'>Todos</option>"; if (miRS != null) while...
1
by: Mike | last post by:
My users have to select an value from a fixed selection of values. The obvious choice of control for such a requirement is to use a <select> (i.e. a combo box). My problem is that sometimes,...
6
by: Chris Fink | last post by:
Does anyone know it is possible to include a small image(.gif .jpeg) within a <SELECT><option> so that the user would see the option text as well as a little image(icon) in the option? I know this...
2
by: mitch | last post by:
I have a <select> that's inside a <td> and I want to dynamically show and hide the select. If elem is set to the <select> and I do either of these: elem.style.visibility = "hidden";...
4
by: luftikus143 | last post by:
Hi there, I have a nasty little problem, as so often, only with IE. Here is an screenshot to better illustrate the problem. http://geodata.grid.unep.ch/screenshot13.png The map is clickable (to...
5
by: Sonnich | last post by:
Can anyone give me a quick hint for this? Say, I have: <SELECT NAME="opt3" SIZE="15" multiple> Then I'd like to list the items selected... echo $_POST; but this gives only the first one ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.