Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Lettera 1 volta sola

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    1,037

    Lettera 1 volta sola

    Ciao a tutti, ho un campo di testo.Quello che vorrei che nel Array testo ci fossero solo le lettere 1 sola volta,dove sbaglio?
    codice:
    function order(a, b) {
    	var nome1 = a;
    	var nome2 = b;
    	if (nome1 < nome2) {
    		return -1;
    	} else if (nome1 > nome2) {
    		return 1;
    	} else {
    		return 0;
    	}
    }
    puls.onPress = function() {
    	var testo = nomeCampodiTesto.text.split("");
    	testo.sort(order);
    	for (var t = 0; t < testo.length; t++) {
    		if (testo[t] == testo[(t + 1)]) {
    			testo.splice((t + 1), 1);
    		}
    	}
    	trace(testo);
    };
    grazie

  2. #2
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    1,037
    grazie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.