// AJAX QUERY - Istruzioni /* AjaxQuery(url) URL = indirizzo della pagina che restituisce i dati AjaxOutputID = elemento nel quale va scritto l'ID dell'elemento in cui mostrare i risultati AjaxReset() Cancella i risultati dall'elemento AjaxOutputID */ //Gets the browser specific XmlHttpRequest Object function getXmlHttpRequestObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest(); //Not IE } else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); //IE } else { //Display your error message here. //and inform the user they might want to upgrade //their browser. alert("Your browser doesn't support the XmlHttpRequest object. Better upgrade to Firefox."); } } //Get our browser specific XmlHttpRequest object. var receiveReq = getXmlHttpRequestObject(); function AjaxQuery(url) { document.getElementById(document.getElementById('AjaxOutputID').value).innerHTML = 'in elaborazione...'; //If our XmlHttpRequest object is not in the middle of a request, start the new asyncronous call. if (receiveReq.readyState == 4 || receiveReq.readyState == 0) { //Setup the connection as a GET call to SayHello.html. //True explicity sets the request to asyncronous (default). receiveReq.open("GET", url , true); //Set the function that will be called when the XmlHttpRequest objects state changes. receiveReq.onreadystatechange = AjaxHandle; //Make the actual request. receiveReq.send(null); } } //Called every time our XmlHttpRequest objects state changes. function AjaxHandle() { //Check to see if the XmlHttpRequests state is finished. if (receiveReq.readyState == 4) { //Set the contents of our span element to the result of the asyncronous call. document.getElementById(document.getElementById('AjaxOutputID').value).innerHTML = receiveReq.responseText; } } function AjaxReset() { document.getElementById(document.getElementById('AjaxOutputID').value).innerHTML = ""; } function AjaxRicaricaSearchBox() { //controllo se tutti i parametri sono selezionati ed eventualmente faccio il submit del form if (document.getElementById('Tipo').value != '' && document.getElementById('Area').value != '' && document.getElementById('dataP').value != '' && document.getElementById('Alloggio').value != '' && document.getElementById('Stelle').value != '' && document.getElementById('Prezzo').value != '' && document.getElementById('Famiglia').value != '' && ($('#btnRicerca').length) ) { document.getElementById('btnRicerca').click(); return false; }; AjaxQuery('/AJAX/AJAX-ricerca.asp?Tipo=' + document.getElementById('Tipo').value +'&Area=' + document.getElementById('Area').value+'&dataP=' + document.getElementById('dataP').value+'&Confine=' + document.getElementById('Confine').value+'&Famiglia=' + document.getElementById('Famiglia').value + '&Prezzo=' + document.getElementById('Prezzo').value + '&Alloggio=' + document.getElementById('Alloggio').value + '&Stelle=' + document.getElementById('Stelle').value +'&s=' + document.getElementById('s').value +'&Rif=' + document.getElementById('Rif').value); } function AjaxRicercaAvanzata() { if (document.getElementById('checknofferte').value == 0){ alert('Non ci sono offerte con questi parametri, prova ad eliminare qualche parametro di ricerca'); return false; } if (document.getElementById('checknofferte').value > 150){ alert('Questa ricerca visualizzerebbe troppe offerte, prova a ridurne il numero scegliendo altri parametri'); return false; } if (document.getElementById('checknofferte').value != 0 && document.getElementById('checknofferte').value <= 150){ document.getElementById('s').value = 'avanzata'; return true; } } function togliFiltro(parametro) { document.getElementById(parametro).value = ''; if (parametro == 'Tipo') { document.getElementById('Area').value = ''; } AjaxRicaricaSearchBox(); } function eliminaFiltri() { document.getElementById('Rif').value = 'ajax'; document.getElementById('Tipo').value = ''; document.getElementById('Area').value = ''; document.getElementById('dataP').value = ''; document.getElementById('Alloggio').value = ''; document.getElementById('Stelle').value = ''; document.getElementById('Prezzo').value = ''; document.getElementById('Famiglia').value = ''; document.getElementById('Confine').value = ''; AjaxRicaricaSearchBox(); } function caricaData (DataMin, DataMax) { $(document).ready(function (){ $('#dataP').live('focus', function(){ $('#dataP').datepicker({ /* dateFormat: 'yy-mm-dd', dateFormat: 'dd/mm/yy', */ changeMonth: true , changeYear: true , minDate: new Date (DataMin), maxDate: new Date (DataMax) }); }); }); }