用户需要能够选择第一和第二时间选项。我正在使用单选按钮......但是,如果有更好的东西,我很感激输入。
当他们选择他们的第一选择时,我想要一条页面消息说“你已经选择了你的第一选择”......当他们选择他们的第二选择时,我想要“你已经选择了你的第二选择”。
是的,我意识到这看起来很简单......我对 jquery 很陌生......
谢谢你的帮助!
HTML:
<table class="tblWorkshop">
<tr>
<td>DAY ONE</td>
</tr>
<th>Morning Workshops</th>
<th></th>
<th></th>
<th></th>
<th>Afternoon Workshops</th>
<th></th>
<th></th>
<tr>
<td>9:00 am</td><td><input type="radio" name="choice" class="firstChoice" value="0" />First Choice</td><td><input type="radio" name="choice" class="secondChoice" value="1" />Second Choice</td><td class="spotsLeft"></td>
<td>12:00 pm</td><td><input type="radio" name="choice" class="firstChoice" />First Choice</td><td><input type="radio" name="choice" class="secondChoice" />Second Choice</td><td class="spotsLeft"></td>
</tr>
<tr>
<td>10:30 am</td><td><input type="radio" name="firstChoice" value="0" class="firstChoice" />First Choice</td><td><input type="radio" name="SecondChoice" value="1" class="secondChoice" />Second Choice</td><td class="spotsLeft"></td>
<td>12:30 pm</td><td><input type="radio" name="firstChoice" value="0" class="firstChoice" />First Choice</td><td><input type="radio" name="SecondChoice" value="1" class="secondChoice" />Second Choice</td><td class="spotsLeft"></td>
</tr>
<tr>
<td>11:00 am</td><td><input type="radio" name="firstChoice" value="0" class="firstChoice" />First Choice</td><td><input type="radio" name="SecondChoice" value="1" class="secondChoice" />Second Choice</td><td class="spotsLeft"></td>
<td>1:00 pm</td><td><input type="radio" name="firstChoice" value="0" class="firstChoice" />First Choice</td><td><input type="radio" name="SecondChoice" value="1" class="secondChoice" />Second Choice</td><td class="spotsLeft"></td>
</tr>
<tr>
<td>11:30 am</td><td><input type="radio" name="firstChoice" value="0" class="firstChoice" />First Choice</td><td><input type="radio" name="SecondChoice" value="1" class="secondChoice" />Second Choice</td><td class="spotsLeft"></td>
<td>2:30 pm</td><td><input type="radio" name="firstChoice" value="0" class="firstChoice" />First Choice</td><td><input type="radio" name="SecondChoice" value="1" class="secondChoice" />Second Choice</td><td class="spotsLeft"></td>
</tr>
<tr>
<td>11:45 am</td><td><input type="radio" name="firstChoice" value="0" class="firstChoice" />First Choice</td><td><input type="radio" name="SecondChoice" value="1" class="secondChoice" />Second Choice</td><td class="spotsLeft"></td>
<td>3:45 pm</td><td><input type="radio" name="firstChoice" value="0" class="firstChoice" />First Choice</td><td><input type="radio" name="SecondChoice" value="1" class="secondChoice" />Second Choice</td><td class="spotsLeft"></td>
</tr>
</table>
脚本:
<script type="text/javascript">
var selected =$('input[name=choice]:checked', '.tblWorkshop').val()
if (selected == $('input[value=1]:checked', '.tblWorkshop').val()) {
alert('First choice selected');
}
else if (selected == $('input[value=0]:checked', '.tblWorkshop').val()){
alert('Second choice selected');
}
});
</script>