html - Using a javascript variable value for <td> tags -


function changefunc9() {     var selectbox9 = document.getelementbyid("schallamach");     selectedvalue9 =selectbox9.options[selectbox9.selectedindex].value;     console.log(selectedvalue9);  } var values = [selectedvalue1, selectedvalue2, selectedvalue3,  selectedvalue4, selectedvalue5, selectedvalue6, selectedvalue7,  selectedvalue8, selectedvalue9]; 

i didn't include entirety of code because consistent each selectedvalue# variable. selectedvalues coming select tags in html user picks list of different options. function storing choice in variable , logging console can make sure worked properly. want use these variables , display value of variables in td tags in table. having difficulty task. selectedvalues in array global. if give me guidance on how assign these variables td, awesome , appreciated. prefer not use jquery. also, using separate js file , linking html. don't know if makes difference.

function valuestotd(values) {    return values.map((value) => {      const td = document.createelement("td")      td.textcontent = value      return td    })  }    function addtotable(values, table) {    const tds = valuestotd(values)    const tr = document.createelement("tr")    tds.foreach(tr.appendchild.bind(tr))    table.appendchild(tr)  }    const selectedvalues = ["one", "two", "three"]  const table = document.queryselector("table")  addtotable(selectedvalues, table)
<table></table>


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -