473,569 Members | 2,991 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="multi ple" size="5">
<option value='43'>Aish a</option>
<option value='40'>Amst erdam</option>
<option value='55'>Asma a</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'>Cora l Queen</option>
<option value='2' selected='selec ted'>Diamond-Heaven</option>
<option value='10'>Disc overy</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 7887

"Felix Natter" <fe**********@l dc.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="multi ple" size="5">
<option value='43'>Aish a</option>
<option value='40'>Amst erdam</option>
<option value='55'>Asma a</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'>Cora l Queen</option>
<option value='2' selected='selec ted'>Diamond-Heaven</option>
<option value='10'>Disc overy</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.*********@co mcast.net> writes:
"Felix Natter" <fe**********@l dc.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="multi ple" size="5">
<option value='43'>Aish a</option>
<option value='40'>Amst erdam</option>
<option value='55'>Asma a</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'>Cora l Queen</option>
<option value='2' selected='selec ted'>Diamond-Heaven</option>
<option value='10'>Disc overy</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**********@l dc.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="multi ple" size="5">
<option value='43'>Aish a</option>
<option value='40'>Amst erdam</option>
<option value='55'>Asma a</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'>Cora l Queen</option>
<option value='2' selected='selec ted'>Diamond-Heaven</option>
<option value='10'>Disc overy</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="multi ple" size="5">
<option value='2' selected='selec ted'>Diamond-Heaven</option>
<option value='43'>Aish a</option>
<option value='40'>Amst erdam</option>
<option value='55'>Asma a</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'>Cora l Queen</option>
<option value='10'>Disc overy</option>
<option value='21'>Dive One</option>
</select>

Jul 20 '05 #4
"Felix Natter" <fe**********@l dc.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.formNa me.elements["boote[]"];
SelectObject.se lectedIndex = SelectObject.se lectedIndex;
}
WD
Jul 20 '05 #5
"Pierre Goiffon" <pg******@nowhe re.invalid> writes:
"Felix Natter" <fe**********@l dc.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="multi ple" size="5">
<option value='43'>Aish a</option>
<option value='40'>Amst erdam</option>
<option value='55'>Asma a</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'>Cora l Queen</option>
<option value='2' selected='selec ted'>Diamond-Heaven</option>
<option value='10'>Disc overy</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="multi ple" size="5">
<option value='2' selected='selec ted'>Diamond-Heaven</option>
<option value='43'>Aish a</option>
<option value='40'>Amst erdam</option>
<option value='55'>Asma a</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'>Cora l Queen</option>
<option value='10'>Disc overy</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*********@we b.de> writes:
"Felix Natter" <fe**********@l dc.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.formNa me.elements["boote[]"];
SelectObject.se lectedIndex = SelectObject.se lectedIndex;
}


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**********@l dc.de> wrote:
"Warden Dave" <wa*********@we b.de> writes:
You could try something simple like +-:

onload = function() {
var SelectObject = document.formNa me.elements["boote[]"];
SelectObject.se lectedIndex = SelectObject.se lectedIndex;
}

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.theFor m.elements["boote[]"];
for (var i=SelectObject. options.length-1; i>=0; i--)
SelectObject.op tions[i].selected = SelectObject.op tions[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
16410
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... It's possible?!? Thanks
7
2016
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 value from the selection fields. Text inputs work just fine. Below is the form and validation script (I've added "...." to indicate additional...
1
1402
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 script does not work. There's no error, it just doesn't properly populate the popup. What's going on here is that the user selects an entry from one...
6
2992
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 (miRS.next()) {
1
2638
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, these combo boxes will have a *large* number of values. There could be any number of values in them from 5 to 5 million (unlikely it would be this...
6
12985
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 is not an ASP.NET related question, but I know this group is knowledgeable and quick with responses. Thanks
2
6191
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"; elem.style.display = "none"; it works in Firefox, but not in IE. In IE the page doesn't change at all.
4
3577
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 enable zoom in and other functions). But in this case, I would like to select a value from the drop-down list, which displays as a "drop-up" list...
5
2466
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 how do I get the rest?
0
7926
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. ...
1
7679
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5223
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
3657
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...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
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.