0
我有一個單選按鈕的表,在第一列上,選項有:jQuery的檢查下TD單選按鈕組單選按鈕
- 「---」
- 「無庫存」
- '隨着股票'
在第二欄,選項有:
- '---'
- 「無庫存」
- 「低」
- 「中」
- 「高」
現在我想做的是,當用戶點擊「否股票」第一列中,應檢查第二列中的「無庫存」無線電選項。
下面是我在做什麼:
HTML:
<table border='1'>
<tr>
<td class="valign_top" style="text-align:left;">
<div class="radio_field">
<input type="radio" class="stock_avail" id="93_stock_avail_0" name="93_stock_avail" value="0" checked=""> ---
</div>
<div class="radio_field">
<input type="radio" class="stock_avail" id="93_stock_avail_No" name="93_stock_avail" value="No"> No Stock
</div>
<div class="radio_field">
<input type="radio" class="stock_avail" id="93_stock_avail_Yes" name="93_stock_avail" value="Yes"> With Stock
</div>
</td>
<td class="sa_sw_td valign_top" style="text-align:left;">
<div class="radio_field">
<input type="radio" class="sa_sw" name="93_sa_sw" id="93_sa_sw_0" value="0" checked=""> ---
</div>
<div class="radio_field">
<input type="radio" class="sa_sw" name="93_sa_sw" id="93_sa_sw_1" value="1"> No Stock
</div>
<div class="radio_field">
<input type="radio" class="sa_sw" name="93_sa_sw" id="93_sa_sw_2" value="2"> Low
</div>
<div class="radio_field">
<input type="radio" class="sa_sw" name="93_sa_sw" id="93_sa_sw_3" value="3"> Medium
</div>
<div class="radio_field">
<input type="radio" class="sa_sw" name="93_sa_sw" id="93_sa_sw_4" value="4"> High
</div>
</td>
</tr>
<tr>
<td class="valign_top" style="text-align:left;">
<div class="radio_field">
<input type="radio" class="stock_avail" id="94_stock_avail_0" name="94_stock_avail" value="0" checked=""> ---
</div>
<div class="radio_field">
<input type="radio" class="stock_avail" id="94_stock_avail_No" name="94_stock_avail" value="No"> No Stock
</div>
<div class="radio_field">
<input type="radio" class="stock_avail" id="94_stock_avail_Yes" name="94_stock_avail" value="Yes"> With Stock
</div>
</td>
<td class="sa_sw_td valign_top" style="text-align:left;">
<div class="radio_field">
<input type="radio" class="sa_sw" name="94_sa_sw" id="94_sa_sw_0" value="0" checked=""> ---
</div>
<div class="radio_field">
<input type="radio" class="sa_sw" name="94_sa_sw" id="94_sa_sw_1" value="1"> No Stock
</div>
<div class="radio_field">
<input type="radio" class="sa_sw" name="94_sa_sw" id="94_sa_sw_2" value="2"> Low
</div>
<div class="radio_field">
<input type="radio" class="sa_sw" name="94_sa_sw" id="94_sa_sw_3" value="3"> Medium
</div>
<div class="radio_field">
<input type="radio" class="sa_sw" name="94_sa_sw" id="94_sa_sw_4" value="4"> High
</div>
</td>
</tr>
</table>
的JavaScript:
$(document).ready(function(){
$('.stock_avail').click(function(){
var value = $(this).val();
console.log("value: " + value);
if(value=='No'){
$(this).next('td').find('radio').val(2);
}
});
});
這可能幫助:http://jsfiddle.net/E6mhM/。
任何想法如何做到這一點? TIA!
感謝您的快速響應阿薩德,但它不工作http://jsfiddle.net/E6mhM/3/ – Mico
@Mico是啊,我編輯它。現在就試試。 –
謝謝你!我可以在5分鐘內接受你的答案... – Mico