我有一個產品頁面可以動態創建項目選項。我想知道是否選擇了第7個選項,但我不知道單選按鈕的「名稱」或「ID」,因爲它們是自動生成的。如何知道是否選擇第7個單選按鈕而不知道名稱或ID
function teasamplecheck() {
\t if(document.form1.radio1[7].checked == true) {
alert("You have selected a sample");
}
else {
// DO NOTHING
}
}
}
});
<!--START: radio-format-->
<div class="radio-format" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
<input type="radio" name="[oname]" id="radio-[value]" value="[value]" onClick="teasamplecheck();validateValues(document.add,1);updateprice();" [selected]>
[feature]
<div class="clear"></div>
</div>
<!--END: radio-format-->
那麼如何我看這組單選按鈕,知道第七屆一個選擇?
但你有一個'value'使用「檢查」...這是最安全的方式去... – Rayon