Javascript 如果在Codeigniter中使用Jquery禁用单选按钮,如何获取其值?

Javascript 如果在Codeigniter中使用Jquery禁用单选按钮,如何获取其值?,javascript,php,jquery,html,codeigniter,Javascript,Php,Jquery,Html,Codeigniter,在应用中,我有一组问题和答案。每个问题都有3套答案,类型为单选按钮。所有问题和答案都以表格形式出现。如果我回答任何问题并单击“下一步”按钮,则该问题的答案将被禁用。 现在我在“下一步”中禁用了它,但在最后一次单击“提交”时禁用了它。然后我将从表单中获取所有值 脚本代码: <script type="text/javascript"> $('.forward').click(function(event) { $('input[type=radio]:checke

在应用中,我有一组问题和答案。每个问题都有3套答案,类型为单选按钮。所有问题和答案都以表格形式出现。如果我回答任何问题并单击“下一步”按钮,则该问题的答案将被禁用。 现在我在“下一步”中禁用了它,但在最后一次单击“提交”时禁用了它。然后我将从
表单中获取所有值

脚本代码:

<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>
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>

问题1?
问题2?
储蓄及;下一个
见报告

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

$(function(){
    $('form').on('submit', function(){
        $(this).find(':radio').prop('disabled', false);
    });
});

那你想要什么?您现在的问题是什么?当我提交时,我无法在禁用时获取所有单选按钮值。没有残疾,我能得到它。那么如何做到这一点呢?使用
readonly
属性而不是禁用。然后您可以接收所有字段值
if($(this).prop('disabled',true)==true)
。。。永远不会是真的。jQuery setter将返回原始jQuery对象,而不是您想要的boolean getter<代码>如果($(this).prop('disabled'))
$(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());
 }