Visualizzazione dei risultati da 1 a 3 su 3
  1. #1
    Utente di HTML.it
    Registrato dal
    May 2010
    Messaggi
    457

    Collezione in javascript come leggerla

    salve ragazzi mi trovo una funzione già fatta che dovrei utilizzarla
    codice:
    function SearchTown( townStr )
    {
    	var theRet = { SearchTown:	
    		[ 
    			{ townId: 182931, townName: "Pisa" },
    			{ townId: 182222, townName: "Pistoia" },
    			{ townId: 142931, townName: "Pisticci" },
    			{ townId: 232212, townName: "Piscinas" }
    		]
    	}
    	return theRet;
    }
    Io credo che theRet sia una collezione, ma come utilizzarla? Come stamparla??

  2. #2
    Moderatore di Annunci siti web, Offro lavoro/collaborazione, Cerco lavoro L'avatar di cavicchiandrea
    Registrato dal
    Aug 2001
    Messaggi
    26,133

    Re: Collezione in javascript come leggerla

    Originariamente inviato da Mitele
    salve ragazzi mi trovo una funzione già fatta che dovrei utilizzarla
    codice:
    function SearchTown( townStr )
    {
    	var theRet = { SearchTown:	
    		[ 
    			{ townId: 182931, townName: "Pisa" },
    			{ townId: 182222, townName: "Pistoia" },
    			{ townId: 142931, townName: "Pisticci" },
    			{ townId: 232212, townName: "Piscinas" }
    		]
    	}
    	return theRet;
    }
    Io credo che theRet sia una collezione, ma come utilizzarla? Come stamparla??
    Per me theRet è un array multi-dimensinale come utilizzarla dipende cosa ci si deve fare, come stamparla idem alert(theRet[]) dovrebbe stampare tutta l'array in un avviso
    Cavicchi Andrea
    Problemi con javascript, jquery, ajax clicca qui

  3. #3
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    3,660
    Un esempio:

    codice:
    for(i=0; theRet.SearchTown.length; i++){
        alert(theRet.SearchTown[i].townId); 
        alert(theRet.SearchTown[i].townName);
    }

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.