your javascript is executing when the page load, if you want to take the value when the button is pressed you need to move the assignment of those values inside a function that execute when the button is pressed
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
|
How to select a value from option using click function
|
2 | 545 | January 17, 2021 | |
| Need Help in Select tag using JS(DOM) | 4 | 321 | June 1, 2021 | |
| Learn HTML Forms by Building a Registration Form - Step 36 | 3 | 209 | March 1, 2024 | |
| Learn Form Validation by Building a Calorie Counter - Step 40 | 7 | 262 | May 30, 2025 | |
|
Eventlistener on <options> always trigger the first click
|
6 | 919 | June 1, 2021 |