一部のラジオ ボタンの値に基づいて div を非表示または表示しようとしています。css はデフォルトで div を display='none' に設定します
ここに入力があります
<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 が定義されていないことを示しています。ありがとうございます。