If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Dynamic text update and actions

Hi, i have actually 2 problems.
1) I need to calculate a total dynamically.
I have an input with the price of a product and next the amount. As the users inserts the amount I would like the total box to give the amount*price number. So if the price is 3 and user inserts:
1 - then total should display 3. Then the user inserts 0 (amount is now 10) total should display 30.
The problem is that when i ask for the value in the onkeyup event of the amount input i don't get the value with the last key (same with onkeypress event). I could add that number (if it's a number) or see if it's backspace or any char but there should be an easy answer.
I solved it by setting a timeout and using a callback function so as to have the latest value of the amount but it's an awfull solution (though not expensive in code).

2) Avoid focus reset when i update the value of the amount.
I've managed to add commas on the fly to the amount like when the user types "1000" the number displayed is "1,000". In firefox it works great but in IE and Chrome it resets the focus each time i update the field. So when you try to move your cursor back it returns to the last position (maybe because the value of the input is changed).