Personal testing is available.
You need to put the definition of variable i in the initialization function, rather than defining it as a global variable.
The above is the detailed content of Use JavaScript to assign a value to a variable based on the value of a drop-down menu. For more information, please follow other related articles on the PHP Chinese website!