我正在嘗試創建一個無線電選擇按鈕,我希望用戶爲特定主題選擇特定號碼。例如,如果受訪者選擇了初創公司或敏捷的新競爭對手= 1,則後續話題的全部1被禁用。單選按鈕被禁用,即使在選擇其他按鈕後也不會啓用
我已經實現了該功能,但是如果我想將先前選擇的1選項更改爲某個相同主題的另一個選項,我可以這樣做,但1不會在選擇另一個選項時自動激活,它保持禁用狀態。
下面是什麼,我想實現圖片..那裏你可以看到我有選擇2在第一個選項,但仍所有的1個單選按鈕被禁用。我希望全部1個按鈕在我選擇其他按鈕後立即激活。
下面是代碼:
$(document).ready(function() {
$(".question tbody tr td").on('click', function() {
var val,
i,
inputVal;
$(this).addClass("checked");
if ($(this).hasClass("checked")) {
val = document.querySelectorAll("td");
val = Array.prototype.slice.call(val);
val.splice(0,1);
inputVal = $(this).find("input").val();
$(".question tbody tr td").find("input[value="+inputVal+"]").attr('disabled',true);
}
})
});
添加表結構..記住表結構不能改變
<tr id="javatbd572915X2X209SQ001" class="answers-list radio-list array2">
<th class="answertext" width="20%">
Start-Ups or agile new competitors
<input type="hidden" name="java572915X2X209SQ001" id="java572915X2X209SQ001" value="1">
</th>
<td class="answer_cell_001 answer-item radio-item" title="1">
<input class="radio" type="radio" name="572915X2X209SQ001" id="answer572915X2X209SQ001-1" value="1" onclick="checkconditions(this.value, this.name, this.type)"><label class="hide read" for="answer572915X2X209SQ001-1">1</label>
</td>
<td class="answer_cell_002 answer-item radio-item" title="2">
<input class="radio" type="radio" name="572915X2X209SQ001" id="answer572915X2X209SQ001-2" value="2" onclick="checkconditions(this.value, this.name, this.type)"><label class="hide read" for="answer572915X2X209SQ001-2">2</label>
</td>
<td class="answer_cell_003 answer-item radio-item" title="3">
<input class="radio" type="radio" name="572915X2X209SQ001" id="answer572915X2X209SQ001-3" value="3" onclick="checkconditions(this.value, this.name, this.type)"><label class="hide read" for="answer572915X2X209SQ001-3">3</label>
</td>
<td class="answer_cell_004 answer-item radio-item" title="4">
<input class="radio" type="radio" name="572915X2X209SQ001" id="answer572915X2X209SQ001-4" value="4" onclick="checkconditions(this.value, this.name, this.type)"><label class="hide read" for="answer572915X2X209SQ001-4">4</label>
</td>
<td class="answer_cell_005 answer-item radio-item" title="5">
<input class="radio" type="radio" name="572915X2X209SQ001" id="answer572915X2X209SQ001-5" value="5" onclick="checkconditions(this.value, this.name, this.type)"><label class="hide read" for="answer572915X2X209SQ001-5">5</label>
</td>
</tr>
檢查你單選按鈕具有相同的「名稱」值。 –
對於同一行是。Ex對於Start-Up主題中的所有單選按鈕都是一樣的,對於靈活或移動工作,其全部相同,但對主題本身不同。例如,如果Startup的名稱爲5X4X,則所有的1,2,3,4,5按鈕都有相同的名稱。同樣,如果Flexible具有5X5X的名稱,則所有Flex的1,2,3,4,5按鈕具有相同的名稱.. – ChanX
你可以添加你的單選按鈕結構的問題 –