[英]How to get button values inside a foreach using jquery and codeigniter?
[英]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 & 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.