0
I have the following table and the respective code and I intend to sort the table alphabetically in order to get " AC / BD / IC " instead of what is.
//javascript para adicionar elementos
function adicionar() {
var disciplina = localStorage.setItem("Disciplina",document.getElementById("nomedisciplina").value);
var nome = localStorage.getItem("Disciplina");
var table = document.getElementById("myTable2");
var row = table.insertRow(1);
var cell1 = row.insertCell(0);
cell1.innerHTML = nome;
}
// HTML , tabela e, botão e input
<table id="myTable2">
<thead>
<tr>
<th>Disciplina</th>
</tr>
</thead>
<tbody>
<tr>
</tr>
</tbody>
</table>
Adicionar nome da disciplina: <input type="text" name="nome" id="nomedisciplina" onkeypress="return onlyAlphabets(event,this);" >
<button id ="adicionardisc" onclick="adicionar()">Adicionar disciplina</button><br>
And what’s your question? Have you tried some sort of sorting code?
– Ricardo Pontual