从JS打开一个组合框 [英] opening a combo box from JS

查看:44
本文介绍了从JS打开一个组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个选择框,我想从JavaScript打开它。

这可能吗?

我不认为这是为了以防你们其中一个人知道。

我试过了combo.click(); ..focus()..选择()

格雷厄姆

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

推荐答案

Laser Lips meinte:
Laser Lips meinte:

您好,我有一个选择框,我想从JavaScript打开它。

这可能吗?
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 :::Bildagenturfürdenalpinen Raum

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


Gregor Kofler写道:
Gregor Kofler wrote:

Laser Lips meinte:
Laser Lips meinte:

> Hi ,我有一个选择框,我想从JavaScript打开它。这可能吗?
>Hi, I have a select box and I''d like to open it from JavaScript. Is
this possible?



No.


No.



在完全驳回这个想法之前,我认为这是值得的。 >
调查是否可以创建输入事件并将其发送给控件,以便控件可能显示所需的行为。

PointedEars < br $> b $ b -

Prototype.js是由那些不懂javascript的人写的

谁不懂javascript。不知道javascript的人不是设计使用javascript的系统的最佳建议来源。

- Richard Cornford,cljs,< f8 ** *****************@news.demon.co.uk>

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>


Gregor Kofleraécrit:
Gregor Kofler a écrit :

Laser Lips meinte:
Laser Lips meinte:

>我有一个选择框,我想打开它来自JavaScript。这可能吗?
>Hi, I have a select box and I''d like to open it from JavaScript. Is
this possible?



No.


No.



select box ==< input type =" select"?

open ==选择列表中的项目(显示选项)?


如果是:


文件。 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;

}

}


函数launchOption(item){

var s = document.myForm.mySelect,o = s。选项;

for(var i = 0,n = o.length; i< n; i ++)

if(o [i] .text == item){

location = o [i] .value;

休息;

}

}


HTML:

======


< form name =" myForm">

< select name =" mySelect">

< ;选项值=" 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'')">转到维基百科< / button>


-

sm

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


这篇关于从JS打开一个组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆