html
`
<fieldset id="persoon">
<legend>mijn gegevens</legend>
<table>
<tbody><tr>
<td>
<label for="bg">Auto gebruik 1 op</label>
</td>
<td>
<input id="bg" name="bg" size="30" type="number" placeholder="Benzine gebruik?">
</td>
</tr>
<tr>
<td>
<label for="kilometer">kilometer per jaar</label>
</td>
<td>
<input id="kilometer" z="" name="kilometer" size="30" type="number" placeholder="ex: 120000 km/pj">
</td>
</tr>
<tr>
<td>
<label for="benzine">prijs benzine </label>
</td>
<td>
<input id="benzine" name="benzine" size="30" type="number">
</td>
</tr>
<tr>
<td>
<input id="submit" type="submit" value="bereken"> </td><td>
</td></tr>
<tr>
<td>
<label for="berekening">Besparing </label>
</td>
<td>
<input id="berekening" name="berekening" size="30" type="number">
</td>
</tr>
`
Javascript/Jquery
$('#submit').click(function(evt) {
evt.preventDefault(); // this will prevent the form from being submitted
var bg = parseFloat($('#bg').val()); // parseFloat for floating point
var bf = parseFloat($('#kilometer').val());
var bd = $('bf').val($('bf').val() + $('bf').val() / bg);
var bz = parseFloat($('#benzine').val());
var total = bz * bd ;
total = total.toFixed(2);
});
好的,所以我想要完成的是有人填写表格:
1: howmany kilometers on 1 liter gas
2: howmany kilometers you drive a year
3: howmuch the gas costs
submit
4:calculation
有人输入他们的东西后,您按“bereken”,它应该计算所有内容并将其放在“besparing”输入字段中,但它不起作用,我找不到任何人来帮助我。
我对此很陌生