对于输入样式“text”,我有一个javascript函数,例如:
document.getElementById("dds1").onkeyup = function() {
updateIt();
};
现在,如果我有一个复选框怎么办?代码会是什么样的?单选按钮怎么样?我将使用什么来获取值(对于复选框,选中或未选中。对于单选按钮,我想要点击哪个按钮)。
以下是单选按钮的代码:
<li id="foli517" class=" ">
<label class="desc" id="shippingChoice" for="Field517_0">
Shipping Options
</label>
<div>
<input id="shippingChoice" name="Field517" type="hidden" value="" />
<span>
<input id="shipping1" name="Field517" type="radio" class="field radio" value="$2.00 Shipping Fee" tabindex="13" checked="checked" />
<label class="choice" for="Field517_0" >
$2.00 Shipping Fee</label>
</span>
<span>
<input id="Field517_1" name="Field517" type="radio" class="field radio" value="I will pick up the items (free shipping)" tabindex="14" />
<label class="choice" for="Field517_1" >
I will pick up the items (free shipping)</label>
</span>
</div>
</li>
答案 0 :(得分:1)
对于复选框:
document.getElementById("checkBox").onclick = function() {
var isChecked = this.checked;
//whatever
};
对于单选按钮:
document.getElementById("radioButton").onclick = function() {
var clickedId = this.id;
//whatever
};