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
- get selected value dropdown
- put selected value array
- create string of tr element , append table before first tr element
Comments
Post a Comment