2012-07-23 68 views
-1

我想做类似this website的事情。如何在单选按钮上单击显示文本区域弹出?

在此,如果你会点击糟糕的选择(单选按钮):

enter image description here

文本区域将出现在灯箱式弹出:

enter image description here

而且当点击提交它关闭。

如果有人可以帮助我创建类似的东西,请告诉我。

在此先感谢。

我用我自己做到了,感谢所有为以下sagestion 点击答案

http://jsfiddle.net/Rajeshkrathor/2eEjz/

+0

尝试避免将开了一个网站,提供的东西一个例子 - 链接往往寿命短,这将使这个问题毫无用处与同类型的问题未来的访客。 – Marty 2012-07-23 05:37:08

+0

好的谢谢,但为什么-3我不知道这种类型的事情。我已经说过我是这个行业的新人。因为这个我的身份证被封锁.. – rkrathor 2012-07-24 05:54:49

+0

我其实并没有降低你的答案(而是试图改善它),所以我没有为你的答案。 – Marty 2012-07-24 06:13:42

回答

0
<div id="somediv"><input type="radio" id="poor" /></div> 

JS:

$("#poor").on("click", function(){ 
    $("#somediv").append('<input type="text"/>'); 
} 
如果你要显示的文本框状态

,你可以使用jQuery模态

http://jqueryui.com/demos/dialog/#modal-form

0

相反,侦听无线电点击的,最好倾听change()事件触发事件,并检查checked属性以及较差的单选按钮选项。

<input type="radio" name="form_question_1" value="poor" /> 

在结合

# listen for a change in the status of poor radio button 
$('input[value=poor]').change(function() { 
    var input_name = $(this).attr('name'); 
    var input_comment_name = input_name + '_comment'; 

    # add a comment field when poor is checked 
    if ($(this).attr('checked') == 'checked') { 
    $(this).append('<input type="text" name="' + input_comment_name + '" />'); 

    # remove any preexisting comment field if poor is unchecked 
    } else if ($('input[name=input_comment_name]').length > 0) { 
    $('input[name=input_comment_name]').remove(); 
    } 
}); 

我没有测试的代码,它是不是超级干净,但你的想法。