我已经有这个,但不知道如何进一步。 当我选择2个单选按钮上面的复选框时,它应该看看它是否被选中,然后当我检查1个单选按钮时,它应该检查那个复选框并将该值添加到总值中。复选框和单选按钮。值
<form name="CalorieForm">
<input type="checkbox" name="gf"> Groente en fruit <br />
  <input type="radio" name="gf1" value="60"> Appel (60 kcal per appel) <br />
  <input type="radio" name="gf2"value="26"> Paprika (26 kcal per paprika) <br />
<br>
<input type="checkbox" name="bpp"> Brood, pasta en peelvruchten <br />
  <input type="radio" name="bpp1" value="111"> Zilvervliesrijst (111 kcal per 100 gram) <br />
  <input type="radio" name="bpp2" value="24"> Sperziebonen(24 kcal per 100 gram)<br />
<br>
<input type="checkbox" name="zvvev"> Zuivel, vlees, vis, ei en vleesvervangers <br />
  <input type="radio" name="zvvev1" value="118"> Kabeljauwfilet (118 kcal per 100 gram) <br />
  <input type="radio" name="zvvev2" value="115"> Biefstuk (115 kcal per 100 gram) <br />
<br>
<input type="checkbox" name="vo"> Vetten en olie <br />
  <input type="radio" name="vo1" value="108"> Olie (108 kcal per eetlepel) <br />
  <input type="radio" name="vo2" value="90"> Halvarine (90 kcal per 25 gram) <br />
<br>
<input type="checkbox" name="v"> Vocht <br />
  <input type="radio" name="v1" value="0"> Thee (0 kcal per 0.5 liter) <br />
  <input type="radio" name="v2" value="0.6"> Coca cola light (0.6 kcal per blikje) <br />
<br>
<input type="button" value="Bereken de calorieën" name="totaal" onClick="BerekeningCalorie()"> <input type="reset" value="Reset" />
<br>
<br>
Aantal calorieën: <input type="text" name="Calorie" size="20"><br />
</form>
这是我的形式^ 在这里,我未完成的javascript V
function berekeningCalorie() {
var totaal = 0
if document.getElementByName("gf").checked {
if document.getElementByName("gf1").checked
totaal += totaal + document.CalorieForm.gf1.value
if document.getElementByName("gf2").checked
totaal += totaal + document.CalorieForm.gf2.value
}
if document.getElementByName("bpp").checked {
if document.getElementByName("bpp1").checked
totaal += totaal + document.CalorieForm.bpp1.value
if document.getElementByName("bpp2").checked
totaal += totaal + document.CalorieForm.bpp2.value
}
}
我问老师如何做到这一点,她说,这应该是这样的(这是我从记忆她给我看的东西)
有人可以为我解决这个问题吗?我不知道如何继续。 (javascript noob)。
'to taal + = totaal + document.CalorieForm.bpp2。值应该是:或者是'total = + document.CalorieForm.bpp2.value'或者'totalal = totaal + document.CalorieForm.bpp2.value' – Pete