Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 11
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2007
    Messaggi
    225

    Problema caricamento script JS in <head>

    Ciao ragazzi! Ho un problema con 2 script che ho inserito nel tag <head> così:

    codice:
    <head>
    <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript" src="ajax/jquery.min.js"></script>
    <script type="text/javascript" src="ajax/comuni.js"></script>
    	
    <script type="text/javascript" src="cal/calendario.js"></script>
    </head>
    dove:
    "jquery.min.js" e "comuni.js" servono per mostrare 3 menu a tendina per la selezione di regione, città e comune

    calendario.js è un semplice calendario in js

    Il problema è che insieme non funzionano (è come se andassero in conflitto), se li inserisco singolarmente allora funzionano....perchè sec voi?

  2. #2
    Moderatore di JavaScript L'avatar di br1
    Registrato dal
    Jul 1999
    Messaggi
    19,998
    Tralasciando jquery.min.js il cui contenuto e' facile da ricavare, ci sara' qualcosa negli altri due che entra in conflitto... ma da una ricerca su google sono indeciso su quale dei millemila script con quel nome esaminare
    Il guaio per i poveri computers e' che sono gli uomini a comandarli.

    Attenzione ai titoli delle discussioni: (ri)leggete il regolamento
    Consultate la discussione in rilievo: script / discussioni utili
    Usate la funzione di Ricerca del Forum

  3. #3
    Utente di HTML.it
    Registrato dal
    Jul 2007
    Messaggi
    225
    cavolo...lo immaginavo...

    ti do i link degli script:

    1) il calendario (l'ho dovuto uppare perkè nn mi ricordo dove l'avevo preso): http://www.mediafire.com/?dfob6i0d1lamlfb

    2) script ajax e db dei comuni:

    http://rickystra.blogspot.com/2011/0...ap-select.html

    grazie br1


    ps: cmq per essere precisi, avevo sistemato l'head in questo modo:

    codice:
    <head>
    	<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
    	<script type="text/javascript" src="ajax/jquery.min.js"></script>
    	<script type="text/javascript" src="ajax/italia.js"></script>
    
    	<script type="text/javascript" src="cal/prototype.js"></script>
    	<script type="text/javascript" src="cal/scriptaculous.js"></script>
    	<script type="text/javascript" src="cal/datepicker.js"></script>
    	
    	<link rel="stylesheet" type="text/css" href="cal/datepicker.css">
    	<link rel="stylesheet" type="text/css" href="./stylesheet.css">
    </head>

  4. #4
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    3,660
    includendo 2 o più framework differenti (prototype e jquery nel tuo caso) si ha un conflitto in quanto entrambi fanno uso del simbolo $

  5. #5
    Utente di HTML.it
    Registrato dal
    Jul 2007
    Messaggi
    225
    e ke posso fare?

  6. #6
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    3,660
    guarda qui e cerca nel forum ci sono molte discussioni legate a questo problema.

  7. #7
    Utente di HTML.it
    Registrato dal
    Jul 2007
    Messaggi
    225
    ok vediamo se ci riesco. Grazie ragazzi!

  8. #8
    Utente di HTML.it
    Registrato dal
    Jul 2007
    Messaggi
    225
    niente da fare...ne ho provato una marea, ma il conflitto c'è sempre...

    sennò ragazzi, mi sapreste indicare uno script simpatico per le province e i comuni in js (e non in ajax visto che mi crea sto conflitto)?

  9. #9
    Utente di HTML.it
    Registrato dal
    Jul 2007
    Messaggi
    225
    ragazzi, ho trovato uno script interessante che sto modificando (sarà faticoso caricare le città e i comuni italiani, ma è fattibile ), ma ho un problema se devo inserire una seconda coppia di menu a tendina. Ecco gli script:

    index.html

    codice:
    <html>
    
    <head>
    	<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1">
    	<script type="text/javascript" src="aspetto/cuntry.js"></script>
    </head>
    
    <body onLoad="Fill_Country(); "> 
    
    
    <table >
        <form name="form1" method="get" action="visualizza.php">
    	<tr>
    	<td class="latoTrasp" >Country 1:</td>
    	<td><select name="cboCountry" style="width:auto;clear:none;" onChange="Fill_States();">
    	<option></option></select></td>
    	</tr>
    	<tr>
    	<td class="latoTrasp" >State 1:</td>
    	<td><select name="cboState" style="width:auto;" onChange="Update_Globals();">
    	<option></option></select></td>
    	</tr>
    	</form>
    	</table>
    	
    	
    	<table >
        <form name="form2" method="get" action="menu.php">
    	<tr>
    	<td class="latoTrasp" >Country 2:</td>
    	<td><select name="cboCountry2" style="width:auto;clear:none;" onChange="Fill_States();">
    	<option></option></select></td>
    	</tr>
    	<tr>
    	<td class="latoTrasp" >State 2:</td>
    	<td><select name="cboState2" style="width:auto;" onChange="Update_Globals();">
    	<option></option></select></td>
    	</tr>
    	</form>
    	</table>
    	
    	</body>
    	</html>

    country.js

    codice:
    //<!--
     
    var gLngMaxStateLength=0;
    var gLngMaxCountryLength=0;
    var gLngNumberCountries=252;
    var gLngNumberStates=0;
    var gLngSelectedCountry=0;
    var gLngSelectedState=0;
    var gArCountryInfo;
    var gArStateInfo;
    // NOTE:
    // Some editors may exhibit problems viewing 2803 characters...
    var sCountryString = "|Afghanistan|Albania|Algeria|American Samoa|Angola|Anguilla|Antartica|Antigua and Barbuda|Argentina|Armenia|Aruba|Ashmore and Cartier Island|Australia|Austria|Azerbaijan|Bahamas|Bahrain|Bangladesh|Barbados|Belarus|Belgium|Belize|Benin|Bermuda|Bhutan|Bolivia|Bosnia and Herzegovina|Botswana|Brazil|British Virgin Islands|Brunei|Bulgaria|Burkina Faso|Burma|Burundi|Cambodia|Cameroon|Canada|Cape Verde|Cayman Islands|Central African Republic|Chad|Chile|China|Christmas Island|Clipperton Island|Cocos (Keeling) Islands|Colombia|Comoros|Congo, Democratic Republic of the|Congo, Republic of the|Cook Islands|Costa Rica|Cote d'Ivoire|Croatia|Cuba|Cyprus|Czeck Republic|Denmark|Djibouti|Dominica|Dominican Republic|Ecuador|Egypt|El Salvador|Equatorial Guinea|Eritrea|Estonia|Ethiopia|Europa Island|Falkland Islands (Islas Malvinas)|Faroe Islands|Fiji|Finland|France|French Guiana|French Polynesia|French Southern and Antarctic Lands|Gabon|Gambia, The|Gaza Strip|Georgia|Germany|Ghana|Gibraltar|Glorioso Islands|Greece|Greenland|Grenada|Guadeloupe|Guam|Guatemala|Guernsey|Guinea|Guinea-Bissau|Guyana|Haiti|Heard Island and McDonald Islands|Holy See (Vatican City)|Honduras|Hong Kong|Howland Island|Hungary|Iceland|India|Indonesia|Iran|Iraq|Ireland|Ireland, Northern|Israel|Italy|Jamaica|Jan Mayen|Japan|Jarvis Island|Jersey|Johnston Atoll|Jordan|Juan de Nova Island|Kazakhstan|Kenya|Kiribati|Korea, North|Korea, South|Kuwait|Kyrgyzstan|Laos|Latvia|Lebanon|Lesotho|Liberia|Libya|Liechtenstein|Lithuania|Luxembourg|Macau|Macedonia, Former Yugoslav Republic of|Madagascar|Malawi|Malaysia|Maldives|Mali|Malta|Man, Isle of|Marshall Islands|Martinique|Mauritania|Mauritius|Mayotte|Mexico|Micronesia, Federated States of|Midway Islands|Moldova|Monaco|Mongolia|Montserrat|Morocco|Mozambique|Namibia|Nauru|Nepal|Netherlands|Netherlands Antilles|New Caledonia|New Zealand|Nicaragua|Niger|Nigeria|Niue|Norfolk Island|Northern Mariana Islands|Norway|Oman|Pakistan|Palau|Panama|Papua New Guinea|Paraguay|Peru|Philippines|Pitcaim Islands|Poland|Portugal|Puerto Rico|Qatar|Reunion|Romainia|Russia|Rwanda|Saint Helena|Saint Kitts and Nevis|Saint Lucia|Saint Pierre and Miquelon|Saint Vincent and the Grenadines|Samoa|San Marino|Sao Tome and Principe|Saudi Arabia|Scotland|Senegal|Seychelles|Sierra Leone|Singapore|Slovakia|Slovenia|Solomon Islands|Somalia|South Africa|South Georgia and South Sandwich Islands|Spain|Spratly Islands|Sri Lanka|Sudan|Suriname|Svalbard|Swaziland|Sweden|Switzerland|Syria|Taiwan|Tajikistan|Tanzania|Thailand|Tobago|Toga|Tokelau|Tonga|Trinidad|Tunisia|Turkey|Turkmenistan|Tuvalu|Uganda|Ukraine|United Arab Emirates|United Kingdom|Uruguay|USA|Uzbekistan|Vanuatu|Venezuela|Vietnam|Virgin Islands|Wales|Wallis and Futuna|West Bank|Western Sahara|Yemen|Yugoslavia|Zambia|Zimbabwe";
    var aStates = new Array();
    
    aStates[0]="";
    aStates[1]="Badakhshan|Badghis|Baghlan|Balkh|Bamian|Farah|Faryab|Ghazni|Ghowr|Helmand|Herat|Jowzjan|Kabol|Kandahar|Kapisa|Konar|Kondoz|Laghman|Lowgar|Nangarhar|Nimruz|Oruzgan|Paktia|Paktika|Parvan|Samangan|Sar-e Pol|Takhar|Vardak|Zabol";
    aStates[2]="Berat|Bulqize|Delvine|Devoll (Bilisht)|Diber (Peshkopi)|Durres|Elbasan|Fier|Gjirokaster|Gramsh|Has (Krume)|Kavaje|Kolonje (Erseke)|Korce|Kruje|Kucove|Kukes|Kurbin|Lezhe|Librazhd|Lushnje|Malesi e Madhe (Koplik)|Mallakaster (Ballsh)|Mat (Burrel)|Mirdite (Rreshen)|Peqin|Permet|Pogradec|Puke|Sarande|Shkoder|Skrapar (Corovode)|Tepelene|Tirane (Tirana)|Tirane (Tirana)|Tropoje (Bajram Curri)|Vlore";
    
    //......ecc ecc.....
    
    aStates[252]="Bulawayo|Harare|ManicalandMashonaland Central|Mashonaland East|Mashonaland West|Masvingo|Matabeleland North|Matabeleland South|Midlands";
    
    
    /* 
     * gArCountryInfo
     * (0) Country name
     * (1) Name length
     * (2) Number of states
     * (3) Max state length
     */
    gLngNumberCountries = sCountryString.split("|").length;
    //gArCountryInfo = new Array(gLngNumberCountries);
    gArCountryInfo=sCountryString.split("|");
    /* 
     * gArStateInfo[country][statenames][namelengths]
     * (0) Country
     * (1) States (Multi-sized Array)
     *    (0) name
     *    (1) nameLength
     */
    gArStateInfo   = new Array(gLngNumberCountries);
    
    /* 
     * fInitgArStateInfo()
     * purpose: build gArStateInfo array
     * gArStateInfo[Country][States][1]
     *   (0) State name
     *   (1) State name length
     * gArStateInfo[i] is an array of state names
     * gArStateInfo[i][j]=state name, name length
     */
    function fInitgArStateInfo() 
    {
    	var i=0, j=0, sStateName="", iNumberOfStates=0;
    	var iMaxLength=0, iLength=0;
    	var oldNumber=0;
    
    	for (i=0;i<gLngNumberCountries;i++) 
    	{
    		// i is selected country
    		iNumberOfStates=aStates[i].split("|").length+1;
    		gLngNumberStates=gLngNumberStates+iNumberOfStates;
    		gArStateInfo[i]=new Array(iNumberOfStates);
    		iMaxLength=0;
    
    		// Add the additional information
    		for (j=0;j<iNumberOfStates;j++) 
    		{
    			if (iLength>iMaxLength) 
    			{
    				iMaxLength=iLength;
    				gArStateInfo[i][j][0]=sStateName;
    			}
    		}
    		gArCountryInfo[i][3]=parseInt(iMaxLength);
    	}
    	Update_Globals();
    	return;
    }
    
    /* 
     * Working on this one.
     * Fills in cboState from the arrays
     * 
     */
    function xFillState() 
    {	
    	var i=0;
    
    	// reset cboState
    	document.form1.cboState.options.length=0;
    
    	// get selected country
    	gLngSelectedCountry=document.form1.cboCountry.selectedIndex;
    
    	// get number of states for selected country
    	gLngNumberStates=gArCountryInfo[[gLngSelectedCountry][2]];
    
    	// update options in cboState
    	for (i=0;i<gLngNumberStates;i++) 
    	{
    		document.form1.cboState.options[i]=new
    		Option(gArStateInfo[[gLngSelectedCountry][i][0]]);
    	}
    	gLngSelectedState=
    	document.form1.cboState.options.selectedIndex;
    
    	return;
    }
    
    /* 
     * FillStates() function works.
     * Fills cboState from aStates
     */
    function Fill_States() 
    {
    	var i=0, iLen=0, iNumStates=0;
     
    	// reset cboState
    	document.form1.cboState.options.length=0;
    	// get selected country
    	gLngSelectedCountry=document.form1.cboCountry.selectedIndex;
    	iNumStates = aStates[gLngSelectedCountry].split("|").length;
     
    	// update the text boxes
    	Update_Globals();
     
    	// file the state combobox with the list of states
    	for (i=0;i<iNumStates;i++) 
    	{
    		document.form1.cboState.options[i]=new 
    		Option(aStates[document.form1.cboCountry.selectedIndex].split("|")[i]);
    	}
    	updSelectState(0);
    	return;
    }
    
    /*
     * FillCountry()
     * gArCountryInfo matrix holds the following information:
     * (0) Country name
     * (1) Name length
     * (2) Number of states
     * (3) Max state length
     */
    function Fill_Country() 
    {
    	var i=0;
    	var sCountryName="";
     
    	// reset cboCountry.options
    	document.form1.cboCountry.options.length=0;
    	// get number of countries from the string
     
    	// ----------------------------------------------------
    	// gArCountryInfo = new Array(gLngNumberCountries, 4);
    	// ----------------------------------------------------
    	for (i=0;i<gLngNumberCountries;i++) 
    	{
    		gArCountryInfo[i]=new Array(4);
    	}
     
    	for (i=0;i<gLngNumberCountries;i++) 
    	{
    		document.form1.cboCountry.options[i]=new Option(sCountryString.split("|")[i]);
    		sCountryName=document.form1.cboCountry.options[i];
    
    		// gArCountryInfo[i][0]=sCountryName;
    		// gArCountryInfo[i][1]=sCountryName.length;
    		// gArCountryInfo[i][2]=aStates.split("|")[i].length;
    		// gArCountryInfo[i][3]=0;
    		gArCountryInfo[i]=
    			[sCountryName, 
    				parseInt(sCountryName.length),
    				aStates,
    			0];
    	}
    
    	fInitgArStateInfo();
    
    	return;
    }
    
    
    function updSelectState(lngState) 
    {
    	if (gLngSelectedCountry>0) 
    	{
    		document.form1.cboState.selectedIndex = lngState;
    	}
    }
    
    /*
     * gArCountryInfo matrix holds the following information:
     * (0) Country name
     * (1) Name length
     * (2) Number of states
     * (3) Max state length
     */
    function Update_Globals() 
    {
    	gLngSelectedCountry=parseInt(document.form1.cboCountry.selectedIndex);
    	gLngSelectedState=parseInt(document.form1.cboState.selectedIndex);
    
    	return;
    }
    
    //-->

    come si può modificare per fargli caricare anche il 2° form?

  10. #10
    Utente di HTML.it
    Registrato dal
    Dec 2010
    Messaggi
    3,660
    sennò ragazzi, mi sapreste indicare uno script simpatico per le province e i comuni in js (e non in ajax visto che mi crea sto conflitto)?
    Ajax non è un linguaggio di programmazione tutti gli script sono scritti in js altrimenti non ti funzionerebbero. Quindi è ovvio che ajax non centra assolutamente niente con il conflitto che viene generato. Come ti ho già detto il conflitto si genere perche usi due framework differenti (entrambi scritti in js, che poi facciano uso della tecnologia ajax è indifferenete) che usano lo stesso simbolo ($). Inoltre non credo sia lo script dei comuni che va in conflitto( a meno che anche questo script utilizzi jquery) ma il dapicker che probabilmente va ad utilizzare il framework prototype. Quindi anche utilizzando un altro script regioni/comuni il conflitto potrebbe rimanere. Hai guardato le vari discussioni sul forum? il problema è stato discusso più e più volte... che cosa non ti è chiaro?

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.