我有一個簡單的2選項單選按鈕。我會認爲我的代碼會工作,並嘗試了很多其他版本,但我只是錯過了一些東西。當單選按鈕更改時,我需要獲取var typeOfCards以進行更改。該變量用於後面的公式中。檢查單擊單選按鈕時變量變爲另一個變量
輸入值155應該改變typeOfCards平等boxCards並檢查應該改變typeOfCards等於singleCards 輸入值145
<input name="SELECT___CD-0035___33" value="155" onclick="change_option('SELECT___CD-0035___33',this.value)" type="radio">Box Cards (Sold in Multiples of 3) <br>
<input checked="checked" name="SELECT___CD-0035___33" value="154" onclick="change_option('SELECT___CD-0035___33',this.value)" type="radio"> Single Cards (Sold in sets of 12 Cards/12 Envelopes)<br>
var singleCards = 12
var boxCards = 3
var typeOfCards = singleCards
$("input[value='155']").click(function() {
typeOfCards = boxCards;
});
$("input[value='154']").click(function() {
typeOfCards = singleCards;
});
就是這樣。謝謝。 – 2012-04-24 03:43:28