如何在javascript中引用“SELECT组件的这个值”? [英] how to refer "this Value of the SELECT component in javascript?

查看:49
本文介绍了如何在javascript中引用“SELECT组件的这个值”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




-

Hop @ Ni



--
Hop@Ni

推荐答案

niyong写道:
niyong wrote:
-
Hop @ Ni
--
Hop@Ni




通常最好将查询放入帖子的主体,而不是主题中的
,它给予回复者一些引用的内容和

维护帖子链。


如果通过SELECT组件的此值你的意思是

当前所选<选项>的值在< select size =" 1">中,从表单外部获取值的方式是:


var selectObject =

document.forms [''formName'']。elements [''selectName''];

var theValue =

selectObject.options [ selectObject.selectedIndex] .value;

来自< select>的
本身:


< select

onchange =" alert(this.options [this.selectedIndex] .value);">


来自此新闻组的常见问题解答:< url:
http://jibbering.com/faq/#FAQ4_13 />


-

| Grant Wagner< gw ***** @ agricoreunited.com>


*客户端Javascript和Netscape 4 DOM参考可用

at:

*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM参考资料:

*
http: //msdn.microsoft.com/workshop/a...ence_entry.asp


* Netscape 6/7 DOM参考资料:

* http://www.mozilla.org/docs/dom/domref /

*为Netscape 7 / Mozilla升级JavaScript的提示

* http: //www.mozilla.org/docs/web-deve...upgrade_2.html



It''s usually best to put your query in the body of the post, not
in the subject, it gives the replier something to quote and
maintains the chain of posts.

If by "this Value of the SELECT component" you mean the value of
the currently selected <option> in a <select size="1">, the way
to obtain the value from outside the form is:

var selectObject =
document.forms[''formName''].elements[''selectName''];
var theValue =
selectObject.options[selectObject.selectedIndex].value;

from the <select> itself:

<select
onchange="alert(this.options[this.selectedIndex].value);">

From the FAQ for this newsgroup: <url:
http://jibbering.com/faq/#FAQ4_13 />

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available
at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html


很久以前在一块土地上,在很远的时间里br />
Grant Wagner< gw ***** @ agricoreunited.com>写道:
In a land long ago, in a time far away
Grant Wagner <gw*****@agricoreunited.com> wrote:
来自< select>本身:

< select onchange =" alert(this.options [this.selectedIndex] .value);">
from the <select> itself:

<select onchange="alert(this.options[this.selectedIndex].value);">




我的印象是这可以(豁免)

缩写为:

< select onChange =" alert(this [this.selectedIndex] .value)">


任何无法获得此功能的浏览器?

你的

P


PatD写道:
PatD wrote:


我一直认为这可以(保存)
缩写为:
< select onChange =" alert(this [this.selectedIndex] .value)">

任何浏览器都不会得到这个?


I''ve been under the impression that this can be (savely)
shortened to:
<select onChange="alert(this[this.selectedIndex].value)">

Any browsers that wouldn''t get this?



这将适用于我所有的浏览器。

Mick


That will work in every browser I have.
Mick


这篇关于如何在javascript中引用“SELECT组件的这个值”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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