我想基于一些单选按钮值隐藏或显示一个DIV,CSS默认的div来显示=“无”隐藏/显示通过单选按钮
这里div的输入
<input type="radio" id="payment_type" value="cash" checked="checked" name="payment_type" onchange="showhideFinancing(this.value);"/> Cash/Debit
<input type="radio" id="payment_type" value="cheque" name="payment_type" onchange="showhideFinancing(this.value);"/> Cheque
<input type="radio" id="payment_type" value="visa" checked="checked" name="payment_type" onchange="showhideFinancing(this.value);"/> VISA
<input type="radio" id="payment_type" value="mc" name="payment_type" onchange="showhideFinancing(this.value);"/> Mastercard
<input type="radio" id="payment_type" value="financing" name="payment_type" onchange="showhideFinancing(this.value);"/> Financing
这里的DIV:
<div id="financing">
...
</div>
我的JavaScript FN看起来是这样的:
function showhideFinancing(payment_type) {
if (payment_type == "financing") {
document.getElementById("financing").style.display = 'block';
} else {
document.getElementById("financing").style.display = 'none';
}
}
Firebug显示getElementById未定义 - 谢谢!
创建jsFiddle:http://jsfiddle.net/r65f6/适合我! – MvanGeest 2010-06-18 15:14:26
感谢您的推荐! – Mikey1980 2010-06-18 15:27:32