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

opening a combo box from JS

Hi, I have a select box and I'd like to open it from JavaScript. Is
this possible?
I don't think it is but just in case one of you knew.
I've tried combo.click(); ..focus() ..select()
Graham
Aug 22 '08 #1
12 2393
Laser Lips meinte:
Hi, I have a select box and I'd like to open it from JavaScript. Is
this possible?
No.

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Aug 22 '08 #2
Gregor Kofler wrote:
Laser Lips meinte:
>Hi, I have a select box and I'd like to open it from JavaScript. Is
this possible?

No.
Before dismissing the idea entirely, I think it would be worthwhile to
investigate if it was feasible to create an input event and dispatch it
to the control, so that the control might show the desired behavior.
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Aug 22 '08 #3
SAM
Gregor Kofler a écrit :
Laser Lips meinte:
>Hi, I have a select box and I'd like to open it from JavaScript. Is
this possible?

No.
select box == <input type="select"?
open == choice an item of the list (show an option) ?

if yes :

document.myForm.mySelect.selectedIndex = 2;
JS :
====

function showOption(item) {
var s = document.myForm.mySelect, o = s.options;
for(var i=0, n=o.length; i<n; i++)
if(o[i].text == item) {
s.selectedIndex = i;
break;
}
}

function launchOption(item) {
var s = document.myForm.mySelect, o = s.options;
for(var i=0, n=o.length; i<n; i++)
if(o[i].text == item) {
location = o[i].value;
break;
}
}

HTML :
======

<form name="myForm">
<select name="mySelect">
<option value="http://www.google.com/">Google</option>
<option value="http://www.yahoo.com/">Yahoo!</option>
<option value="http://en.wikipedia.org/">Wiki</option>
</select>
</form>
<button onclick="showOption('Yahoo!')">Show Yahoo!</button>
<button onclick="launchOption('Wiki')">Go to Wikipedia</button>

--
sm
Aug 22 '08 #4
Thomas 'PointedEars' Lahn meinte:
Gregor Kofler wrote:
>Laser Lips meinte:
>>Hi, I have a select box and I'd like to open it from JavaScript. Is
this possible?
No.

Before dismissing the idea entirely, I think it would be worthwhile to
investigate if it was feasible to create an input event and dispatch it
to the control, so that the control might show the desired behavior.
I doubt that - it would be a click event dispatched to the control, and
then I think it is completely up to the browser's behaviour whether
you'd get the according "visual feedback". Anyway, it won't be easy -
most likely - and it won't work on "most browsers". I suppose it would
be easier and more "cross browser" to fake a dropdown entirely with an
ordinary input plus other block elements (like all those suggest widgets).

Gregor

--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Aug 23 '08 #5
SAM meinte:
Gregor Kofler a écrit :
>Laser Lips meinte:
>>Hi, I have a select box and I'd like to open it from JavaScript. Is
this possible?

No.

select box == <input type="select"?
open == choice an item of the list (show an option) ?
[code snipped]

So what? That selects an option, but it won't "drop" the list of the
dropdown. At least that's what I think the OP want's.

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Aug 23 '08 #6
Gregor Kofler wrote:
SAM meinte:
>Gregor Kofler a écrit :
>>Laser Lips meinte:
Hi, I have a select box and I'd like to open it from JavaScript. Is
this possible?
No.
select box == <input type="select"?
open == choice an item of the list (show an option) ?

[code snipped]

So what? That selects an option, [...]
Does it? `select' is not a (Valid) value for the `type' attribute of the
`input' element in the first place.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Aug 23 '08 #7
Thomas 'PointedEars' Lahn meinte:
Gregor Kofler wrote:
>SAM meinte:
>>select box == <input type="select"?
open == choice an item of the list (show an option) ?
[code snipped]

So what? That selects an option, [...]

Does it? `select' is not a (Valid) value for the `type' attribute of the
`input' element in the first place.
I didn't understand those two lines and just skipped them. I was
referring to the snipped code below. I should have snipped everything...

Gregor
--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Aug 23 '08 #8
SAM
Gregor Kofler a écrit :
SAM meinte:
>Gregor Kofler a écrit :
>>Laser Lips meinte:
Hi, I have a select box and I'd like to open it from JavaScript. Is
this possible?

No.

select box == <input type="select"?
open == choice an item of the list (show an option) ?

[code snipped]

it won't "drop" the list of the dropdown.
Do not understand what that means (dropping)
(translation word to word in french has no meaning)
perhaps a picture of the feature ?

or do you mean something like :
Unwind, unfold(display), show all the list ?

--
sm
Aug 23 '08 #9
SAM meinte:
or do you mean something like :
Unwind, unfold(display), show all the list ?
Yes.

Gregor

--
http://photo.gregorkofler.at ::: Landschafts- und Reisefotografie
http://web.gregorkofler.com ::: meine JS-Spielwiese
http://www.image2d.com ::: Bildagentur für den alpinen Raum
Aug 23 '08 #10
SAM
Gregor Kofler a écrit :
SAM meinte:
>or do you mean something like :
Unwind, unfold(display), show all the list ?

Yes.
OK.

function openDropdown() {
var s = document.myForm.mySelect;
s.size = o.length
}
function closeDropdown() {
var s = document.myForm.mySelect;
s.size = '';
}

:-)

--
sm
Aug 24 '08 #11
On Aug 24, 1:08 am, SAM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
Gregor Kofler a écrit :
SAM meinte:
or do you mean something like :
Unwind, unfold(display), show all the list ?
Yes.

OK.

function openDropdown() {
var s = document.myForm.mySelect;
s.size = o.length}

function closeDropdown() {
var s = document.myForm.mySelect;
s.size = '';

}

:-)

--
sm
That would not work because it would push everything below it down.

Don't think it it's possible.

Graham
Aug 26 '08 #12
SAM
Laser Lips a écrit :
On Aug 24, 1:08 am, SAM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
>>
function openDropdown() {
var s = document.myForm.mySelect;
s.size = o.length}

function closeDropdown() {
var s = document.myForm.mySelect;
s.size = '';

}

:-)

That would not work because it would push everything below it down.
there was a smiley !
Don't think it it's possible.
certainly something as a tiptool could simulate the feature

here is using simple css :

<style type="text/css">
form p { position: relative; height: 1em }
form p select { position: absolute; z-index: 100 }
</style>

works (if it could say) in Firefox, Safari
not tested IE

<http://cjoint.com/data/iAmOH3aFc7_open_select.htm>

--
sm
Aug 26 '08 #13

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

Similar topics

2
by: Aravind | last post by:
Hi folks. I have a combo box with a list of names. I want to be able to click (or press "enter" on) a name, which will open a separate form which shows a group of records that corresponds to...
1
by: Todd | last post by:
My form contains a combo box and the "not in list" event is triggerred when the user enters a value that is not among the values listed in the combo box. I want the user to be able to add a new...
3
by: Rony Steelandt | last post by:
Hi, Does somebody knows a way to automaticely open the list part of a wxCombobox when it gets the focus ? tia, Rony
7
by: sara | last post by:
I have a form where the user selects an item from a list box, and then works on that item. The user chooses an AD, then opens a form to assign departments to the ad. The top of the Depts form has...
3
by: ducky | last post by:
I need help with opening a report when a button is clicked, but I only want to open the report with the Object I have chosen in the combo box. This is what i have so far: 'If 2 is selected open...
1
by: omar.norton | last post by:
I am trying to create a from with a series of combo boxes that each query a different field (called Specific01, Specific02 etc., except the first field which is called Condition). Each combo box...
1
by: abhishekbrave | last post by:
The code below is opening a calendar on mouse over in the same window. I need the calendar to be opened in new window. Have to fulfill this requirement urgentely so posting the whole code here. I...
11
by: casan.mike | last post by:
Hi all, I have a form called "customer_frm" with many records in it. I would like to have a form that has a combobox listing all the customers, and a button that open the "customers_frm" to...
6
by: John J. | last post by:
In my combo's list I have for instance these values: AbcdX AbcdY When I press A in the combo, AbcdX gets selected though I need AbcdY to be selected. With Alt-ArrowDown I can dropdown the list,...
2
by: damonrulz | last post by:
I have a combo box with a list in. I want to be able to click on one of the values in this combo box, and a form will open. The difficult thing is that i want a different form to open for each value...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.