Please could you help me with some JS? I only know my way around HTML/JS and I'm stuck here.
I would like the user to enter two numbers. The fist number is multiplied by 25, which works.
The second number is supposed to be added to the first result. However, as the second result I only get the second number added in writing after the first result, but not added mathematically.
How do I need to change the code below?
<input type="text" id="Editbox1" name="quantity1" value="" wrap
val = this.value;
<input type="text" id="Editbox2" name="amount1" value="" onFocus="this.blur" readonly >
<input type="text" id="Editbox3" name="quantity1" value="" wrap
val = this.value;
<input type="text" id="Editbox4" name="amount" value="" onFocus="this.blur" readonly >
If you want an integer (no decimals), you can use parseInt(number), so for example:
parseInt(this.form.amount1.value) + parseInt(this.value)
If you want decimals, there's parseFloat() etc, but floating point calculations in JS aren't much fun.
Thanks dnordstrom, very helpful.
But I seems I'm not done with it – need more assistance
Could you please have a look here: http://www.fightforsight.org.uk/carrots-regfee
Of course, the "Total to play" field doesn't update as it should. It only updates properly once the user enters something into the donation field (plus if the '0' isn't changed it displays "NaN").
How would I need to change the code for the Total field to update straight away, and so that a user can just tab through without haveing to overtype and change the '0' for donation?
Also, is there an easy way to make the first field "Number of participants..." a drop-down? Users should only really give a number from 1 to 6 here...
Sorry is I'm asking a lot here, and thanks for any help!
This topic is now closed. New replies are no longer allowed.