//Created by Sean Kane (http://celtickane.com/programming/code/ajax.php) //Feather Ajax v1.0.1 // Modified to use a '^' as the deliminator rather than the default '|' // set the searchform url for ajax data var ajax_url = '/apps/inc/ajax_searchboxes/ajax_searchform_vert_v2-5.php'; function AjaxObject101() { this.createRequestObject = function() { try { var ro = new XMLHttpRequest(); } catch (e) { var ro = new ActiveXObject("Microsoft.XMLHTTP"); } return ro; } this.sndReq = function(action, url, data) { if (action.toUpperCase() == "POST") { this.http.open(action,url,true); this.http.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); this.http.onreadystatechange = this.handleResponse; this.http.send(data); } else { this.http.open(action,url + '?' + data,true); this.http.onreadystatechange = this.handleResponse; this.http.send(null); } } this.handleResponse = function() { if ( me.http.readyState == 4) { if (typeof me.funcDone == 'function') { me.funcDone();} var rawdata = me.http.responseText.split("^"); for ( var i = 0; i < rawdata.length; i++ ) { var item = (rawdata[i]).split("=>"); if (item[0] != "") { if (item[1].substr(0,3) == "%V%" ) { document.getElementById(item[0]).value = item[1].substring(3); } else { document.getElementById(item[0]).innerHTML = item[1]; } } } } if ((me.http.readyState == 1) && (typeof me.funcWait == 'function')) { me.funcWait(); } } var me = this; this.http = this.createRequestObject(); var funcWait = null; var funcDone = null; } function ajaxCheckFormValues (frmObj){ var iValidationCounter = 0; var alertMsg = "The following fields are required:\n"; var frmEle = frmObj.elements; // we always need a state choosen if (frmEle['State'].value == "") { alertMsg += " * Pick a State\n"; iValidationCounter = iValidationCounter + 1; } // based on search type we need to validate different fields switch (frmEle['SearchType'].value) { case "zip_search": if (frmEle['ZipCode[]'].value == "") { alertMsg += " * Pick a ZipCode\n"; iValidationCounter = iValidationCounter + 1; } break; case "community_name": if (frmEle['Community_Name[]'].value == "") { alertMsg += " * Pick a Community\n"; iValidationCounter = iValidationCounter + 1; } break; case "builder_name": if (frmEle['Builder_Name[]'].value == "") { alertMsg += " * Pick a Builder\n"; iValidationCounter = iValidationCounter + 1; } break; default: if (frmEle['City[]'].value == "") { alertMsg += " * Pick a City\n"; iValidationCounter = iValidationCounter + 1; } } if (iValidationCounter == 0){ return true; } else { alert(alertMsg); return false; } } // try to self fire so we dont need the tags on the html page var ao = new AjaxObject101(); ao.sndReq('get', ajax_url,'lookup=display_form&City[]=middletown&SearchType=com&State=new_jersey&PriceLow=&PriceHigh=&fp_hometype=&fp_sqft=&fp_beds=&fp_baths=');