我正在尝试创建一个无线电选择按钮,我希望用户为特定主题选择特定号码。例如,如果受访者选择了初创公司或敏捷的新竞争对手= 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
你可以添加你的单选按钮结构的问题 –