What I am trying is the following : I have 2 buttons and one textfield (code you see below) On the buttons there is a value on it : 0,20 and 0,05. When you press one of the buttons the value should be displayed in the textfield and when you press one of those buttons again the value should be added to the current value. Here is the code I have at the moment :
<input id="bedraggroot" type="button" value="0.20" onClick="b();">
<input id="bedragklein" type="button" value= "0.05" onClick="b();">
<p> Ingeworpen : <span id="toonbedrag"> Ingeworpen </span></p>
function b()
{
var bedrag1 = parseFloat(document.getElementById('bedraggroot').value);
var bedrag2 = parseFloat(document.getElementById('bedragklein').value);
var totaalbedrag;
if(bedrag1 == 0)
{
parseFloat(totaalbedrag)+ bedrag2;
}
if(bedrag2 == 0)
{
parseFloat(totaalbedrag) = totaalbedrag + bedrag1;
tussenbedrag = tussenb
}
document.getElementById('toonbedrag').innerHTML = totaalbedrag;
}
I already tried al bunch of stuff but nothing seem to work what I try. without the parseFloat, with a + before it. (Read all those things in these forums) Can someone help me out?
As you might know, I am just a beginner in these things.
Kind regards.