Creating Dropdown Dynamically - Javascript

前端 未结 2 731
情话喂你
情话喂你 2020-12-19 15:22

I\'m trying to develop a JS function that creates a new row each time a new record is added to a database (from a different program that checks periodically). Right now I ca

2条回答
  •  无人及你
    2020-12-19 15:47

    After

    textnode2 = document.createElement("select");
    

    you need to do something like

    var op = new Option();
    op.value = 1;
    op.text = "First entry";
    textnode2.options.add(op);      
    

    and repeat for your desired entries.

提交回复
热议问题