473,804 Members | 3,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

open the options box associated with a select

I have a select named "s" in a form named "f":

By default only one of the options in the select appears on the page --
that is how I want it.

What I'd like to do is simulate a click on the select so that all of
its options become visible -- i.e., its option box opens to reveal all
document.f.s.op tions.length options.

I've tried the following:
1. document.f.s.op tions[k].selected=true
2. document.f.s.fo cus()
3. document.f.s.cl ick()
4. document.f.s.si ze=document.f.s .options.length
1. succeeds in changing the option which is visible but leaves the
displayed number unchanged
2. highlights the currently visible option-- indicating focus has been
received
3. appears to do nothing
4. this changes the size of the visible rectangle, and is sort of what
I want, except that the other options appear above the select's prior
rectangle (hence disrupting extant page layout) rather than allowing
the other options to "drop down" below as should happen when physically
clicking on a select.

I might just have to build a widget to do this, but thought someone
might know of the proper method for effecting this behavior.

TIA
ddailey

Apr 9 '06 #1
11 1536

"ddailey" <dd*****@zoomin ternet.net> wrote in message
news:11******** **************@ t31g2000cwb.goo glegroups.com.. .
I have a select named "s" in a form named "f":

By default only one of the options in the select appears on the page --
that is how I want it.

What I'd like to do is simulate a click on the select so that all of
its options become visible -- i.e., its option box opens to reveal all
document.f.s.op tions.length options.
TIA
ddailey


This is not exactly what you were wanting, but all options become visible.

var theSize = document.forms["f"].elements["s"].length;
document.forms["f"].elements["s"].size = theSize;

then change theSize back to 1 and run the 2nd line again when you're done.
it doesn't simulate a click, but all the options become visible.
HTH
Apr 9 '06 #2
Jim
Hi There DDaily,
plse check the following code out.
Hopefully this is what you were looking for:
<form name="f">
<select name="s" onChange="this. multiple='true' , this.size='5'">
<option selected value=''>--- Automobile Types --- </option>
<option value="ford">Fo rd</option>
<option value="chevy">C hevrolet</option>
<option value="honda">H onda</option>
<option value="toyota"> Toyota</option>
</select>
</form>
The prior poster's code is more flexible as it detects the options
length, which in the case of the above, (which is more specific) needs
to be hard-coded into the form itself.

In any event, I hope this helps!
-Jim

Apr 9 '06 #3
Hal Rosser wrote:
This is not exactly what you were wanting, but all options become
visible.
var theSize = document.forms["f"].elements["s"].length;
document.forms["f"].elements["s"].size = theSize;


Using similar logic, check out this proof of concept I did a while ago:
http://www.mattkruse.com/temp/expand_select.html

It's not perfect and doesn't work in all cases but it's interesting.

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Apr 9 '06 #4
Jim wrote:
<form name="f">
The `action' attribute is required, setting the `name' attribute is
unnecessary here.
<select name="s" onChange="this. multiple='true' , this.size='5'">


This may or may not work. The `multiple' property is of type boolean
(true), not string ('true'). The `size' property is of type number (5),
not string ('5').

I do not see anything in the OP that justifies modifying the value of
the `multiple' property here, thereby changing the behavior of the
control completely.
PointedEars
Apr 9 '06 #5

"Matt Kruse" <ne********@mat tkruse.com> wrote in message
news:e1******** *@news4.newsguy .com...
Hal Rosser wrote:
This is not exactly what you were wanting, but all options become
visible.
var theSize = document.forms["f"].elements["s"].length;
document.forms["f"].elements["s"].size = theSize;


Using similar logic, check out this proof of concept I did a while ago:
http://www.mattkruse.com/temp/expand_select.html

It's not perfect and doesn't work in all cases but it's interesting.


Kool, it works in IE, but in Firefox it changes back too quick.
Apr 10 '06 #6
Hal Rosser said on 10/04/2006 11:23 AM AEST:
"Matt Kruse" <ne********@mat tkruse.com> wrote in message
news:e1******** *@news4.newsguy .com...
Hal Rosser wrote:
This is not exactly what you were wanting, but all options become
visible.
var theSize = document.forms["f"].elements["s"].length;
document.for ms["f"].elements["s"].size = theSize;


Using similar logic, check out this proof of concept I did a while ago:
http://www.mattkruse.com/temp/expand_select.html

It's not perfect and doesn't work in all cases but it's interesting.

Kool, it works in IE, but in Firefox it changes back too quick.


Matt's use of a default button causes the form to submit (in Firefox),
which appears to make the select 'change back'. IE's implementation of
a button may be buggy in this respect.

Use a button (or input) type="button" and that goes away (another reason
to always specify attributes, even when you want the default).

<URL:http://www.w3.org/TR/html4/interact/forms.html#edef-BUTTON>
--
Rob
Group FAQ: <URL:http://www.jibbering.c om/FAQ>
Apr 10 '06 #7
RobG wrote:
Matt's use of a default button causes the form to submit (in Firefox),
which appears to make the select 'change back'. IE's implementation
of a button may be buggy in this respect.


Good catch. This page was a quick hack I did for an IE-specific site a while
ago just to prove the concept. There are a few things which should certainly
be cleaned up before using it for real!

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Apr 10 '06 #8
ddailey wrote:
I have a select named "s" in a form named "f":

By default only one of the options in the select appears on the page --
that is how I want it.

What I'd like to do is simulate a click on the select so that all of
its options become visible -- i.e., its option box opens to reveal all
document.f.s.op tions.length options.

I've tried the following:

....

There is a bug logged in Firefox
(https://bugzilla.mozilla.org/show_bug.cgi?id=303713) that is supposed
to be fixed for the next release (after 1.5.0.1) that would allow you
to do this in FF by sythesizing an alt+down_arrow keypress event and
dispatching it at the select element.

Not wanting to wait, I rewrote my GreaseMonkey extension to include
GM_sendKeys (documented at
http://www.nabble.com/GM_sendKeys-t1421601.html) - example 3 shows how
it covers your situation - and now I can do this on my machines. (In
case you don't know, GreaseMonkey is an extension to FF that allows one
to modify the pages (or page behaviour of the pages that you view on
your own computers).

Csaba Gabor from Vienna

Apr 11 '06 #9

"RobG" <rg***@iinet.ne t.au> wrote in message
news:vu******** ***********@new s.optus.net.au. ..

Matt's use of a default button causes the form to submit (in Firefox),
which appears to make the select 'change back'. IE's implementation of
a button may be buggy in this respect.

Use a button (or input) type="button" and that goes away (another reason
to always specify attributes, even when you want the default).

<URL:http://www.w3.org/TR/html4/interact/forms.html#edef-BUTTON>


Hmmm - learn something new every day.
So the form 'submits' without a 'submit' button? But its not supposed to,
right?

Apr 12 '06 #10

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

Similar topics

12
6561
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the courses to pass the correct option value and then be displayed at the following URL: http://www.dslextreme.com/users/kevinlyons/selectResults.html I am passing countries, products, and courses. The first two display
8
6298
by: Rob Wahmann | last post by:
I'm having trouble with the following code appending the form name and an empty value to the end of the url. Can anyone tell me what's wrong? I appreciate any tips or advice you can pass along! Rob // submits info like this: http://www.google.com/?select= <script type="text/javascript"> function launchIt() {
5
2253
by: Dave | last post by:
I reinstalled SQL 2000 server after reformatting my drive. Now I cannot open a database in my C## program as before. If I use "Provider=SQLOLEDB;Data Source=localhost; Initial Catalog=master;Integrated Security=SSPI"; I get an Invalid login error. If I use "Provider=SQLOLEDB; Data Source=localhost; Initial Catalog=master;User ID=Dave;Password=midn1te"; I get the following error, "User no associated with a trusted SQL server...
20
7217
by: fniles | last post by:
I am using VB.NET 2003, SQL 2000, and SqlDataReader. As I read data from tblA, I want to populate tblB. I use SQLDataReader for both tables. I do not use thread. When I ExecuteReader on tblB, I get the error "There is already an open DataReader associated with this Connection which must be closed first." How can I fix this error ? For each DataReader, do I want to open and close the connection (in this case adoCon) to avoid this error ?...
13
3420
by: Bart | last post by:
Hi, i get the error: "There is already an open DataReader associated with this Command which must be closed first" Thanks Bart ----------------------------------------- Imports System.Data.sqlclient
3
13198
by: BLUE | last post by:
I've a TransactionScope in which I select some data and I want to do some queries for each record retrieved with my select. I'm using a DataReader and for each record I do factory.CreateCommand() and then I execute the command, but I get the following exception message: " There is already an open DataReader associated with this Command which must be closed first. " Searching on google I've found I've to create another connection, but...
0
4974
by: Salad | last post by:
A97. Split database. Frontend DB1.MDB. Backend DB1BE.MDB. Tables are linked between DB1 and DB2. From my testing, if I open DB1 exclusively using /excl the backend DB1BE is not opened exclusively. If I open DB1 but have no tables open and then open up DB1BE exclusively, DB1BE will open exclusive. But if I then attempt to open a linked table in the frontend DB1 I'm informed I can't use the table because the file is in use.
0
9705
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10564
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10320
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10308
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
6846
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5513
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5645
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4288
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
2
3806
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.