< select..onchange()>只有一个<选项> [英] <select..onchange() > with only one <option>

查看:47
本文介绍了< select..onchange()>只有一个<选项>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这是一个讨厌的人,我看不出我的出路。


我有一堆选择陈述表单和每个选择语句

有一个onchange =" do_something(this)"在其中,这很有效。

很好..除非在给定的选择中只有一个OPTION。

看来你不能''改变''一个选项!


嗯,这是合理的。


麻烦的是我没办法选择它,因为表格本身是一个

dummy:表单操作基本上是提交到一个新的脚本,并使用

隐藏变量仔细设置以获得所需的操作,具体取决于

选择的最后一个选项。 。


onclick()在< optionitself中对IE6不起作用......


有没有人能想办法实现我想要的?

有问题的片段就是这个片段


< TR>< TD align =" center">< b> ;朱利安的项目< / b>< / td>

< TD align =" center">< select STYLE =" width:200px" name =" project_id"

onchange =" select_project_id(this)">

< OPTION value =" 13" > ME-262(2007年9月13日)< / OPTION>

< / select>< / TD>< / TR>


这可以通过多个选项实现惊人的效果。但是只需要一个就可以使用




制作单个选项SELECTED的选项是一个非首选项,作为

在其他选择语句中有其他选项可以取消选择这个

one ..once取消选中我再也找不到了!

我想我在整个选择的东西上尝试了一个onclick(),但它并没有
工作得太好。


This is a nasty one and I can''t see my way out of it.

I have a bunch of select statements in a form, and each select statement
has an onchange="do_something(this)" in it, and this works
nicely..except when there is only ONE OPTION in a given select.
It seems you cannot ''onchange'' a single option!

Well, that is reasonable.

The trouble is I have no way of selecting it since the form itself is a
dummy: The form action is basically to submit to a new script with
hidden variables carefully set to get the desired action depending on
the last option selected..

onclick() in the <optionitself doesn''t work for IE6...

Can anyone think of a way to achieve what I want?
The fragment in question is this one

<TR><TD align="center"><b>Julian''s Projects</b></td>
<TD align="center"><select STYLE="width: 200px" name="project_id"
onchange="select_project_id(this)">
<OPTION value= "13" >ME-262 (Sep 13th 07)</OPTION>
</select></TD></TR>

This works stunningly with more than one option..but falls apart with
just one.

The option of making the single option SELECTED is a non starter, as
there are other options in other select statements that deselect this
one..once deselected I can''t ever get it back!

I think I tried an onclick() on the whole select thing, but it didn''t
work too well.

推荐答案

自然哲学家写道:
The Natural Philosopher wrote:

>

这是一个讨厌的,我不能看看我的出路。


我在表单中有一堆select语句,每个select语句

有一个onchange =" do_something(此)"在其中,这很有效。

很好..除非在给定的选择中只有一个OPTION。

看来你不能''改变''一个选项!


嗯,这是合理的。


麻烦的是我没办法选择它,因为表格本身是一个

dummy:表单操作基本上是提交到一个新的脚本,并使用

隐藏变量仔细设置以获得所需的操作,具体取决于

选择的最后一个选项。 。


onclick()在< optionitself中对IE6不起作用......


有没有人能想办法实现我想要的?


有问题的片段就是这个片段


< TR>< TD align =" center"> ;< b> Julian'的项目< / b>< / td>

< TD align =" center">< select STYLE =" width:200px" name =" project_id"

onchange =" select_project_id(this)">

< OPTION value =" 13" > ME-262(2007年9月13日)< / OPTION>

< / select>< / TD>< / TR>


这可以通过多个选项实现惊人的效果。但是只需要一个就可以使用




制作单个选项SELECTED的选项是一个非首选项,作为

在其他选择语句中有其他选项可以取消选择这个

one ..once取消选中我再也找不到了!

我想我在整个选择的东西上尝试了一个onclick(),但它并没有让b $ b工作得太好。

>
This is a nasty one and I can''t see my way out of it.

I have a bunch of select statements in a form, and each select statement
has an onchange="do_something(this)" in it, and this works
nicely..except when there is only ONE OPTION in a given select.
It seems you cannot ''onchange'' a single option!

Well, that is reasonable.

The trouble is I have no way of selecting it since the form itself is a
dummy: The form action is basically to submit to a new script with
hidden variables carefully set to get the desired action depending on
the last option selected..

onclick() in the <optionitself doesn''t work for IE6...

Can anyone think of a way to achieve what I want?
The fragment in question is this one

<TR><TD align="center"><b>Julian''s Projects</b></td>
<TD align="center"><select STYLE="width: 200px" name="project_id"
onchange="select_project_id(this)">
<OPTION value= "13" >ME-262 (Sep 13th 07)</OPTION>
</select></TD></TR>

This works stunningly with more than one option..but falls apart with
just one.

The option of making the single option SELECTED is a non starter, as
there are other options in other select statements that deselect this
one..once deselected I can''t ever get it back!

I think I tried an onclick() on the whole select thing, but it didn''t
work too well.



嗯,我似乎已经通过用onclick替换onchange()修复了它()


似乎onclick(this)获取了正确的值

this.SelectedIndex ..


哦好吧。 Javascript通过人们的理解等方式

Hmm., I seem to have fixed it by replacing onchange() with onclick()

It seems that onclick(this) picks up the correct value in
this.SelectedIndex..

Oh well. The ways of Javascript passeth man''s understanding etc.


9月26日下午7:53,自然哲学家< a ... @ b.cwrote:
On Sep 26, 7:53 pm, The Natural Philosopher <a...@b.cwrote:

这是一个讨厌的人,我看不出我的出路。


我有一堆表单中的select语句和每个select语句

有一个onchange =" do_something(this)"在其中,这很有效。

很好..除非在给定的选择中只有一个OPTION。

看来你不能''改变''一个选项!


嗯,这是合理的。


麻烦的是我没办法选择它,因为表格本身是一个

dummy:表单操作基本上是提交到一个新的脚本,并使用

隐藏变量仔细设置以获得所需的操作,具体取决于

选择的最后一个选项。 。


onclick()在< optionitself中对IE6不起作用......


有没有人能想办法实现我想要的?
This is a nasty one and I can''t see my way out of it.

I have a bunch of select statements in a form, and each select statement
has an onchange="do_something(this)" in it, and this works
nicely..except when there is only ONE OPTION in a given select.
It seems you cannot ''onchange'' a single option!

Well, that is reasonable.

The trouble is I have no way of selecting it since the form itself is a
dummy: The form action is basically to submit to a new script with
hidden variables carefully set to get the desired action depending on
the last option selected..

onclick() in the <optionitself doesn''t work for IE6...

Can anyone think of a way to achieve what I want?



如果只有一个选项,为什么要使用选择?不会吗?b $ b隐藏的输入更有意义吗?

Why use a select at all if there is only one option? Wouldn''t a
hidden input make more sense?


David Mark写道:
David Mark wrote:

9月26日晚上7:53,自然哲学家< a ... @ b.cwrote:
On Sep 26, 7:53 pm, The Natural Philosopher <a...@b.cwrote:

>这是一个令人讨厌的,我看不出我的方式。

我在表单中有一堆select语句,每个select语句
有一个onchange =" do_something (本)"在它,这很好地工作
很好..除非在给定的选择中只有一个OPTION。
似乎你不能''改变''一个选项!

嗯,这是合理的。

问题是我无法选择它,因为表单本身是一个假人:表单操作基本上是用选择的最后一个选项..

onclick()在< optionitself中不适用于IE6 ...

谁能想到一种方法来实现我想要的东西?
>This is a nasty one and I can''t see my way out of it.

I have a bunch of select statements in a form, and each select statement
has an onchange="do_something(this)" in it, and this works
nicely..except when there is only ONE OPTION in a given select.
It seems you cannot ''onchange'' a single option!

Well, that is reasonable.

The trouble is I have no way of selecting it since the form itself is a
dummy: The form action is basically to submit to a new script with
hidden variables carefully set to get the desired action depending on
the last option selected..

onclick() in the <optionitself doesn''t work for IE6...

Can anyone think of a way to achieve what I want?



如果只有一个选项,为什么要使用select?不会吗?b
$隐藏的输入更有意义吗?


Why use a select at all if there is only one option? Wouldn''t a
hidden input make more sense?



首先因为一旦用户添加了更多的东西,那么就会超过

一个选项,其次是因为在更多的方框中有更多选项

其他地方。


我使用SELECT / OPTION作为一种方便的方式生成各种弹出列表

而不深入Javascript。


有几个列表,都有一个或多个选项..我需要选择

来自所有列表中的一项并继续使用。

与onchange()或onclick()相关联的javascript确实

确实是补丁无论如何,在一个隐藏变量的值。


无论如何,使用onclick()工作除了客户端说它不在

IE7和我没有那个可以测试。好吧。


如果一切都失败了我可以用纯javascript弹出klists写它

和沟渠选项/选择一起..

Firstly because once the user has added more stuff there IS more than
one option, and secondly because there are more options in more boxes
elsewhere.

I used SELECT/OPTION as a handy way of generating various pop up lists
without going to deep into Javascript.

There are several lists, all with one or more options..I need to select
ONE item from ALL the lists and go with that.
The javascript associated with the onchange() or onclick() stuff does
indeed patch in a value to a hidden variable anyway.

Anyway, using onclick() worked except the client is saying it doesn''t in
IE7 and I haven''t got that to test with. Ah well.

If all else fails I may ye write it with pure javascript pop up klists
and ditch option/select altogether..


这篇关于&lt; select..onchange()&gt;只有一个&lt;选项&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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