469,356 Members | 2,117 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,356 developers. It's quick & easy.

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 2234
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Aravind | last post: by
3 posts views Thread by Rony Steelandt | last post: by
1 post views Thread by omar.norton | last post: by
11 posts views Thread by casan.mike | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.