In the game, the player has a list of equipment and can purchase different quantities of each item (or none). Each item has a cost, and I would like to add code to automatically show the total cost before the player submits their purchase.
Example: If the user wants to purchase 5 of ITEM A which costs 20, and 3 of ITEM B which costs 60, the total field will automatically update to show 280. If the user changes any of these values, the total will automatically update again, without having to re-submit the form.
The quantity is entered by the user in a standard HTML text input field. The item's price is fetched from a database, and can be included in the form or other HTML as needed.
The attached image shows a portion of the current screen. In this example, the total field would show "290" as this is the total in the screenshot (E.G. 60 x 2 + 5 x 10 + 25 x 3 + 5 x 15 = 290). If the user were to change any of the quantities, the total field would immediately update.