Salve, ho creato un elenco puntato con l'apposito codice html, solo che le varie voci non sono in ordine alfabetico. C'è un codice per ordinarli senza dover ricreare l'elenco da capo?
Grazie.
Moderatori: Anthony47, Triumph Of Steel, archimede
<html>
<head>
<title>Test sort</title>
<script>
function sortList(listId) {
// Get the ul object
var oUl = document.getElementById(listId);
/* Perform a Bubble Sort on the list items */
for(var i in oUl.childNodes) {
var x = oUl.childNodes[i];
for(var j in oUl.childNodes) {
var y = oUl.childNodes[j];
if((x.innerText != 'undefined' || y.innerText != 'undefined') && x.innerText>y.innerText) {
// Skip if x is already the first list item
if(oUl.firstChild!=x)
oUl.insertBefore(y,x);
}
}
}
}
/* Define innerText for Mozilla based browsers */
if((typeof HTMLElement != 'undefined') && (HTMLElement.prototype.__defineGetter__ != 'undefined')) {
HTMLElement.prototype.__defineGetter__("innerText", function () {
var r = this.ownerDocument.createRange();
r.selectNodeContents(this);
return r.toString();
});
}
window.onload=function() {
sortList("names");
}
</script>
</head>
<body>
<ul id="names">
<li>X</li>
<li>C</li>
<li>B</li>
<li>W</li>
</ul>
</body>
</html>
Inserimento dati su tabella da codice a barre Autore: systemcrack |
Forum: Applicazioni Office Windows Risposte: 80 |
menu a tendina con filtro per selezione elenco Autore: marcus69 |
Forum: Applicazioni Office Windows Risposte: 13 |
Creare un elenco numerato di titoli in excel come in word Autore: wallace&gromit |
Forum: Applicazioni Office Windows Risposte: 8 |
definizione automatica di nomi da un elenco Autore: marcoc |
Forum: Applicazioni Office Windows Risposte: 4 |
Visitano il forum: Nessuno e 6 ospiti