1
なぜ私のjsが機能しないのですか?私は私のラジオをクリックすると無効にラジオを作る が、その作業をしないようにしようと イムラジオボタンを無効にしようとするとjavascriptが機能しない
誰かが私をここに役立つだろう希望私のコード だ
function tester() {
for (var i = 0; i < document.forms[0].elements.length; i++) {
if (document.forms[0].elements[i].name == "optradio1") {
if (document.forms[0].elements[i].value == "pinjdn") {
if (document.forms[0].elements[i].checked == true) {
document.forms[0].soptradio[0].disabled = true;
document.forms[0].soptradio[1].disabled = true;
document.forms[0].soptradio[2].disabled = true;
document.forms[0].soptradio[3].disabled = true;
}
} else if (document.forms[0].elements[i].value == "hibahln") {
if (document.forms[0].elements[i].checked == true) {
document.forms[0].soptradio[0].disabled = false;
document.forms[0].soptradio[1].disabled = false;
document.forms[0].soptradio[2].disabled = false;
document.forms[0].soptradio[3].disabled = false;
}
}
}
}
}
<div class="col-sm-6 well">
<div class="row">
<form name="form1" method="post" action="">
<table class="table table-striped">
<tr>
<th>Beban</th>
<th>
<label>
<input type="radio" name="optradio1" value="rm" id="hide">RM</label>
<label>
<input type="radio" name="optradio1" value="pinjln" id="show">Pinj LN</label>
<label>
<input type="radio" name="optradio1" value="localcost" id="show2">Local Cost</label>
<label>
<input type="radio" name="optradio1" value="pnbp" id="hide2">PNBP</label>
<label>
<input type="radio" name="optradio1" value="pinjdn" id="show3" onClick="tester()">Pinj DN</label>
<label>
<input type="radio" name="optradio1" value="hibahdn" id="hide3">Hibah DN</label>
<label>
<input type="radio" name="optradio1" value="hibahln" id="show4" onClick="tester()">Hibah LN</label>
</th>
</tr>
</table>
</form>
</div>
<div class="row">
<div class="abc">
<div class="col-sm-12">
<form name="form1" method="post" action="">
<table class="table table-striped">
<tr>
<div class="radio">
<th>Jenis Bantuan</th>
<th>
<label>
<input type="radio" name="soptradio">Pinjaman Valas</label>
<label>
<input type="radio" name="soptradio" checked>Pinj. RPLN</label>
<label>
<input type="radio" name="soptradio">Hibah Valas</label>
<label>
<input type="radio" name="soptradio">Hibah RPLN</label>
</th>
</div>
</tr>
</table>
</form>
私を助けてください はあなたに感謝
私の説明は誰にとっても明白です。
ありがとうございます
:以下の変更されたコードを参照してください。 あなたの機能のように見えません。 '
' – DanilGholtsmanに入れてください。両方の 'form'要素は、' name'属性 'form1" 'に同じ値を持っています。 'name'' 'soptradio''を持つ' input'要素は 'document.forms [0]'ではなく 'document.forms [1]'の子要素です。 – guest271314