473,406 Members | 2,451 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,406 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 2399
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.