Select dropdown menu option with javascript

前端 未结 2 1293
长发绾君心
长发绾君心 2021-02-05 02:30

I have a dropdown menu and I cannot figure out how to make a javascript function select a drop down menu option. I have tested the output of the variables and they are all corre

2条回答
  •  一向
    一向 (楼主)
    2021-02-05 03:11

    Change the line that reads:

    document.getElementById("stateSelect").selected = true;

    to:

    document.getElementById("stateSelect").selectedIndex = i;

提交回复
热议问题