Ok, I give you some example. If the user select 5 hours, then the total cost should be $100. But if the user select to 3 hours later, then it should be $60 ($20 * 3) as $20 is default as per hour.
You can notice that the Input text for Total Cost is disabled. The calculation has to be done by JavaScript so the user can't directly edit it before the form can be submitted.
Anyway, I am not sure about how to code it correctly as whenever I changed the option from DropDown List, for e.g. when I selected 7 hours, then $20 became $140. However, when I selected 2 hours, it became $280 ($40 was supposed to be displayed instead of $280). I am not sure about implementing the correct code for JavaScript. Anyone who can help with this? Thanks
Question
Novawin
Hi
Look at the picture below.
Ok, I give you some example. If the user select 5 hours, then the total cost should be $100. But if the user select to 3 hours later, then it should be $60 ($20 * 3) as $20 is default as per hour.
Here is my incompleted and sample code
You can notice that the Input text for Total Cost is disabled. The calculation has to be done by JavaScript so the user can't directly edit it before the form can be submitted.
Anyway, I am not sure about how to code it correctly as whenever I changed the option from DropDown List, for e.g. when I selected 7 hours, then $20 became $140. However, when I selected 2 hours, it became $280 ($40 was supposed to be displayed instead of $280). I am not sure about implementing the correct code for JavaScript. Anyone who can help with this? Thanks
It's very simple one. :rolleyes:
Link to comment
Share on other sites
5 answers to this question
Recommended Posts