选择一个radiobutton和一个相应的文本框将显示/可见 [英] select a radiobutton and a correspinding text box will show/visible

查看:101
本文介绍了选择一个radiobutton和一个相应的文本框将显示/可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好

i有这些单选按钮,我希望在选择单选按钮时可以看到相应的文本框。


任何帮助?

片段。

谢谢



感谢您的支持

Bry



这里是html:


[HTML]<!DOCTYPE html PUBLIC" - // W3C // DTD XHTML 1.0 Transitional / / EN" http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

< html xmlns =" http://www.w3.org / 1999 / xhtml">

< head>


< meta http-equiv =" Content-Type"含量=" text / html的;字符集= ISO-8859-1" />



< / head>


< body>

< tr>

< td>


< form>

< input type =" radio" ;名称= QUOT; RadiobuttonGroup1"值= QUOT; Radio_button1"> Radio_button1

< br>

< input type =" radio"名称= QUOT; RadiobuttonGroup1"值= QUOT; Radio_button2"> Radio_button2

< br>

< input type =" radio"名称= QUOT; RadiobuttonGroup1"值= QUOT; Radio_button3"> Radio_button3

< br>

< input type =" radio"名称= QUOT; RadiobuttonGroup1"值= QUOT; Radio_button4"> Radio_button4

< / form>


< / td>

< td>

< form>

texbox 1:

< input type =" text" name =" texbox1">

< br>

texbox 2:

< input type =" text" name =" texbox2">

< br>

texbox 3:

< input type =" text" name =" texbox3">

< br>

texbox 4:

< input type =" text" name =" texbox4">

< / form>


< / td>

< / tr> ;


< / body>

< / html> [/ HTML]

解决方案

< blockquote> Heya,Bry。欢迎来到TSDN!


你想为每个单选按钮添加一个onclick处理程序,它隐藏所有文本框,只显示与该单选按钮对应的文本框。 />

您可能还必须手动设置每个单选按钮的checked属性,因为为无线电控件设置onclick处理程序往往会中断正常的事件触发。


提示:

  • 隐藏元素:

    展开 | 选择 | Wrap | 行号


    谢谢

    到目前为止我拥有这个。它不是我想要的工作。


    它没有显示每个单选按钮的相应文本框。


    而不是它只是隐藏选中单选按钮2时的两个文本框

    并在选中单选按钮1时显示两个文本框。


    <!------- --------------------这里是-------帮助谢谢------------------ --->


    [HTML]< html>


    < head>

    < script type =" text / javascript">

    function hide(){

    var div_ref = document.getElementById(" id_textbox_1");

    div_ref.style.visibility =" hidden";

    }


    function show(){

    var div_ref = document.getElementById(" id_textbox_1");

    div_ref.style.visibility =" visible";

    }


    >
    < / script>



    < / head>


    < body> ;

    < tr>

    < td>

    选择单选按钮类型< BR>

    < / td>

    < td style =" width:200">

    < input type =" Radio"名称= QUOT;&的RadioButtonGroup QUOT;值= QUOT; Radiobutton1"的onclick = QUOT;显示();" checked =" checked">单选按钮1

    < input type =" Radio"名称= QUOT;&的RadioButtonGroup QUOT;值= QUOT; Radiobutton2"的onclick = [隐藏();"未选中>单选按钮2

    < / td>

    < td>

    < div id = id_textbox_1 style =" visibility:隐藏;">

    显示文本框1

    < input type =" Text" name =" Textbox1"

    Show Textbox2

    < input type =" Text" name =" Textbox2"

    < / div>

    < / td>

    < / tr>


    < / body>

    < / html> [/ HTML]



    谢谢

    到目前为止我有这个。它不是我想要的工作。


    它没有显示每个单选按钮的相应文本框。


    而不是它只是隐藏选中单选按钮2时的两个文本框

    并在选中单选按钮1时显示两个文本框。


    <!------- --------------------这里是-------帮助谢谢------------------ --->

    展开 | 选择 | Wrap | 行号


    Hello
    i have these radio buttons and i wish to have the corresponding textboxes to be visible when the radiobutton is selected.

    any Help?
    snippets.
    thanks


    thanks in adv
    Bry


    here is the html:

    [HTML]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />



    </head>

    <body>
    <tr>
    <td>

    <form>
    <input type="radio" name="RadiobuttonGroup1" value="Radio_button1"> Radio_button1
    <br>
    <input type="radio" name="RadiobuttonGroup1" value="Radio_button2"> Radio_button2
    <br>
    <input type="radio" name="RadiobuttonGroup1" value="Radio_button3"> Radio_button3
    <br>
    <input type="radio" name="RadiobuttonGroup1" value="Radio_button4"> Radio_button4
    </form>

    </td>
    <td>

    <form>
    texbox 1:
    <input type="text" name="texbox1">
    <br>
    texbox 2:
    <input type="text" name="texbox2">
    <br>
    texbox 3:
    <input type="text" name="texbox3">
    <br>
    texbox 4:
    <input type="text" name="texbox4">
    </form>

    </td>
    </tr>

    </body>
    </html>[/HTML]

    解决方案

    Heya, Bry. Welcome to TSDN!

    You''ll want to add an onclick handler for each radio button that hides all of the textboxes and shows only the textbox that corresponds to that radio button.

    You may also have to manually set the checked property of each radio button, as setting an onclick handler for radio controls tends to disrupt normal event firing.

    Hints:
    • To hide an element:

      Expand|Select|Wrap|Line Numbers


    Thanks
    so far i have this. it is not working how i wanted to be.

    it is not showing corresponding text box per radio button.

    instead it is just hiding both text box when the radio button2 is selected
    and showing both textbox when the radio button1 is selected.

    <!---------------------------here it is-------HELP THANKS--------------------->

    [HTML]<html>

    <head>
    <script type="text/javascript">
    function hide() {
    var div_ref = document.getElementById("id_textbox_1");
    div_ref.style.visibility = "hidden";
    }

    function show() {
    var div_ref = document.getElementById("id_textbox_1");
    div_ref.style.visibility = "visible";
    }


    </script>



    </head>

    <body>
    <tr>
    <td>
    Select radio button type <BR>
    </td>
    <td style="width:200">
    <input type="Radio" name="RadiobuttonGroup" value="Radiobutton1" onclick="show();" checked="checked">Radio button 1
    <input type="Radio" name="RadiobuttonGroup" value="Radiobutton2" onclick="hide();" unchecked>Radio button 2
    </td>
    <td>
    <div id=id_textbox_1 style="visibility:hidden;">
    Show Textbox1
    <input type="Text" name="Textbox1">
    Show Textbox2
    <input type="Text" name="Textbox2">
    </div>
    </td>
    </tr>

    </body>
    </html>[/HTML]


    Thanks
    so far i have this. it is not working how i wanted to be.

    it is not showing corresponding text box per radio button.

    instead it is just hiding both text box when the radio button2 is selected
    and showing both textbox when the radio button1 is selected.

    <!---------------------------here it is-------HELP THANKS--------------------->

    Expand|Select|Wrap|Line Numbers


    这篇关于选择一个radiobutton和一个相应的文本框将显示/可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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