私はウェブサイトを作ろうとしています。それは質問をするページがあり、選択されたラジオボタンに応じて2つの回答のうちの1つが表示されます。 「はい」を選択すると、失敗したことが通知されます。 5つすべてを「いいえ」として選択すると、合格したことが伝えられます。私は3つの質問だけがあったが、2つを合計して合計5つを追加しようとしたときにコードを変更して動作しなくなったときに、この作業を行った。私が選択した選択肢に関係なく、それは私に答えを与えることはありません。JavaScriptが破損し続ける
このHTML
<form id="myForm">
<fieldset>
<h3>
<legend>Eligibility Test</legend>
</h3>
</fieldset>
<p>Please Answer the following questions to determine if you are eligible for expungement.</p>
<fieldset>
<legend>Have you had your record expunged before?</legend>
<input id="exp_yes" type="radio" name="field1" value="0" />
<label>
Yes
</label>
<input id="exp_no" type="radio" name="field1" value="1" />
<label>
No
</label>
</fieldset>
<fieldset>
<legend>Do you have any charges pending against you?</legend>
<input id="chg_yes" type="radio" name="field2" value="0" />
<label>
Yes
</label>
<input id="chg_no" type="radio" name="field2" value="1" />
<label>
No
</label>
</fieldset>
<fieldset>
<legend>Have any of your convictions ever been for a murder/manslaughter or attempt of the same?</legend>
<input id="mur_yes" type="radio" name="field3" value="0" />
<label>
Yes
</label>
<input id="mur_no" type="radio" name="field3" value="1" />
<label>
No
</label>
</fieldset>
<fieldset>
<legend>Have any of your convictions been for a sex crime or required you to sign up for the sex offender registry?</legend>
<input id="off_yes" type="radio" name="field4" value="0" />
<label>
Yes
</label>
<input id="off_no" type="radio" name="field4" value="1" />
<label>
No
</label>
</fieldset>
<fieldset>
<legend>Do you still owe any fines, fees, or restitution on any of criminal convictions?
</legend>
<input id="fin_yes" type="radio" name="field5" value="0" />
<label>
Yes
</label>
<input id="fin_no" type="radio" name="field5" value="1" />
<label>
No
</label>
</fieldset>
<fieldset id="submitbutton">
<input type="button" id="submit" value="submit" onclick='answer()' />
</fieldset>
<div id="first">
<p id="totalScore"></p>
</div>
</form>
これは私のJavaScript
function answer(total) {
var score = 0;
if (document.getElementById('exp_no').checked) {
score++;
}
if (document.getElementById('chg_no').checked) {
score++;
}
if (document.getElementById('mur_no').checked) {
score++;
}
if (document.getElementById('off_no').checked) {
score++;
}
if (document.getElementById('fin_no').checked) {
score++;
}
if (score != 5) {
document.getElementById('totalScore').innerHTML = "You may not yet be
fully eligible to get your record expunged.Though this test should not be
considered as a definite answer.Please call 574 - 931 - 2173 or visit our
contact page to schedule a meeting
for a proper assessment.
";
toggletab();
} else {
document.getElementById('totalScore').innerHTML = "You appear to be eligible
for expungment!Please contact 574 - 931 - 2173 or visit our contact page to
schedule a meeting and to talk to about your next steps!";
toggletab2();
}
}
function answer(total) {
var score = 0;
if (document.getElementById('exp_no').checked) {
score++;
}
if (document.getElementById('chg_no').checked) {
score++;
}
if (document.getElementById('mur_no').checked) {
score++;
}
if (document.getElementById('off_no').checked) {
score++;
}
if (document.getElementById('fin_no').checked) {
score++;
}
if (score != 5) {
document.getElementById('totalScore').innerHTML = "You may not yet be
fully eligible to get your record expunged.Though this test should not be
considered as a definite answer.Please call 574 - 931 - 2173 or visit our
contact page to schedule a meeting
for a proper assessment.
";
toggletab();
} else {
document.getElementById('totalScore').innerHTML = "You appear to be eligible
for expungment!Please contact 574 - 931 - 2173 or visit our contact page to
schedule a meeting and to talk to about your next steps!";
toggletab2();
}
}
ですが、それは私がそれを調整しようとすると、破壊し続ける理由を、私は本当に理解していない、ありがとう。
あなたは「壊れる」ということをどういう意味ですか?あなたはあなたが得ているエラーを貼り付けることができますか? – fejanto