javascript - How to push values from a dropdown to an array and add the array to a table? -


this javascript. select has id of 'counties'.

the table inserted div called 'up_bottom'.

var leaguearray = []; function addteams() {   var county=document.getelementbyid("counties");   var val = county.options[county.selectedindex].value;   leaguearray.push(val);   function display() {     var table = document.createelement("table");     (var i=0; i<leaguearray.length; i++) {       var row = table.insertrow();       (var j=0; j<leaguearray[i].length; j++) {         var cell = row.insertcell();         cell.appendchild(document.createtextnode(leaguearray[i]));       }     }     var tablediv = document.getelementbyid("up_bottom");     tablediv.appendchild(table);   }   display(); } 

please following steps

  1. get selected value dropdown
  2. put selected value array
  3. create string of tr element , append table before first tr element

Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -