繁体   English   中英

如何使用Codeigniter中的Jquery禁用单选按钮的值?

[英]How to get values of radio button if they are disabled using Jquery in Codeigniter?

在应用程序中,我有一组问题和答案。 每个问题有3组答案,其类型为单选按钮。所有问题和答案均采用表格形式。 如果我回答任何问题并单击下一步按钮,则该问题的答案将被禁用。 现在我在下一个禁用它,但是最后一次当我单击Submit.then我从form提交获取所有值。

脚本代码:

<script type="text/javascript">
    $('.forward').click(function(event) {
       $('input[type=radio]:checked').each(function(index, el) {
           var title = $(this).attr('name');
            $("input[name="+title+"]:radio").attr('disabled',true);

       });
    });
</script>

在Codeigniter代码中:

function insertValues() {
     $answer = $this->input->post();
}

HTML代码:

<form method="post" action="http://localhost/demo/insertValues">

<div>
<h3>Question 1 ?</h3>
<input name="1" type="radio" value="111">
<input name="1" type="radio" value="112">
<input name="1" type="radio" value="113">
</div>

<div>
<h3>Question 2 ?</h3>
<input name="2" type="radio" value="121">
<input name="2" type="radio" value="122">
<input name="2" type="radio" value="123">
</div>

<button type="button" name="forward" class="forward">Save &amp; Next</button>


<button type="submit" name="submit" class="submit">See Report</button>
</form>

一种可能是在提交事件处理程序中启用它们

$(function(){
    $('form').on('submit', function(){
        $(this).find(':radio').prop('disabled', false);
    });
});
 $('form input[type=radio]').each(function(){
      if($(this).prop('disabled',true) == true)
           alert('My property is disabled'+$(this).val());
 }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM