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>
Codice VBA per stampare UserForm attiva Autore: Carletto Ribolla |
Forum: Applicazioni Office Windows Risposte: 8 |
Scelta da elenco a discesa che ne apre un altro Autore: Ricky0185 |
Forum: Applicazioni Office Windows Risposte: 12 |
Codice per popolare celle con condizione Autore: ucame |
Forum: Applicazioni Office Windows Risposte: 3 |
Inserimento dati su tabella da codice a barre Autore: systemcrack |
Forum: Applicazioni Office Windows Risposte: 80 |
Visitano il forum: Nessuno e 6 ospiti