隐藏/显示文本+ TextField [英] Hide/Show Text + TextField

查看:80
本文介绍了隐藏/显示文本+ TextField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这已被发布并多次询问,但我似乎仍无法找到适合我情况的答案。我是javascripting的新手,并且一直在教自己,因为需要脚本。下面是我当前的问题:


我需要一个允许用户选择是的脚本。和否从下拉框中。当是时选择,说明和文本字段将显示在该下拉框下方。如果他们选择否,则不会出现说明和文本字段。


问题二是我只能使用javascript来执行此操作(我使用的界面是严格的)。


有什么想法吗?

I know this has been posted and asked about many times, but I still cannot seem to find an answer that fits my situation. I am pretty new with javascripting, and have been teaching myself as the need arises for a script. Heres my current problem:

I need a script that would allow a user to choose "Yes" and "No" from a drop down box. When "Yes" is chosen, instructions and a textfield will display below that drop down box. If they choose "No", the instructions and textfield do not appear.

Problem two is that I can only use javascript to do this (the interface I use is strict).

Any thoughts?

推荐答案

创建一个选择框。如你所说,在其中做两个选项:''是''和''不''。
Onclick 两个选项的事件,添加一个函数,说 displayHide( )的。但两次提供不同的论点。 (即 true false

[HTML]< select>

< option onclick =" ; displayHide(true)"> Yes< / option>

< option onclick =" displayHide(false)"> No< / option>

< / select> [/ HTML]


现在创建一个包含文本的div。

[HTML]< div id =" mytext" ;>你的文字在这里< / div> [/ HTML]


现在创建函数 displayHide(flag),它将隐藏或显示文本,具体取决于标志
Make a select box. As you said, make two options in it: ''yes'' and ''no''.
Onclick event of both the options, add a function, say displayHide(). But provide different argument both times. (ie. true and false)
[HTML]<select>
<option onclick="displayHide(true)">Yes</option>
<option onclick="displayHide(false)">No</option>
</select>[/HTML]

Now make a div which will contain your text.
[HTML]<div id="mytext">your text here</div>[/HTML]

Now make the function displayHide(flag) which will hide or display the text depending upon the flag.
展开 | 选择 | Wrap | 行号


感谢快速回复hsriat。我很急忙在会议之前把这篇文章发布出去,我忽略了提到我使用表格,不能在这个界面中使用CSS,而在表格中隐藏一行是最简单的选择。由于界面的构建方式,我也无法为是或否选项设置Onclick选项。


我想我可能在这里上了一条小溪,但是想要回复这些信息,看看你是否有任何想法,并为在最后一篇文章上浪费你的时间而道歉。
Thanks for the quick reply hsriat. It seems in my hurriedness to get this post out before a meeting, I neglected to mention that I use tables, cannot use CSS within this interface, and that hiding a row in the table would be the easiest option. I am also not able to set the Onclick options for the Yes or No options due to the way the interface is built.

I think I may be up a creek here, but wanted to reply with that information and see if you had anymore thoughts, along with apologizing for wasting your time with the last post.



感谢你快速回复hsriat。我很急忙在会议之前把这篇文章发布出去,我忽略了提到我使用表格,不能在这个界面中使用CSS,而在表格中隐藏一行是最简单的选择。由于界面的构建方式,我也无法为是或否选项设置Onclick选项。


我想我可能在这里上了一条小溪,但是想要回复这些信息,看看你是否有任何想法,并为在最后一篇文章上浪费你的时间而道歉。
Thanks for the quick reply hsriat. It seems in my hurriedness to get this post out before a meeting, I neglected to mention that I use tables, cannot use CSS within this interface, and that hiding a row in the table would be the easiest option. I am also not able to set the Onclick options for the Yes or No options due to the way the interface is built.

I think I may be up a creek here, but wanted to reply with that information and see if you had anymore thoughts, along with apologizing for wasting your time with the last post.



然后,您可以动态地为选择选项提供该功能。

Then you may dynamically provide the function to the select options.

展开 | 选择 | Wrap | 行号


这篇关于隐藏/显示文本+ TextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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