Buscar
Creating search data
Instrucciones basicas
Ejemplo con HTML y jQuery.
Establezca los datos de búsqueda con los parámetros seleccionados y envíe los datos por url a la página de resultados
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">google.load('jquery', '1.7.1');</script>
<script type="text/javascript">google.load('jqueryui', '1.8.13');</script>
<p>Operation Type</p>
<select id="operationType">
<option value='-1'>Select an Operation Type</option>
<option value='1'>Sale</option>
<option value='2'>Rent</option>
<option value='3'>Temporary Rent</option>
</select>
<p>Property Type</p>
<select id="propertyTypes">
<option value='-1'>Select a Property Type</option>
<option value='1' >Land / Terreno</option>
<option value='2' >Appartment / Departamento</option>
<option value='3' >House / Casa</option>
<option value='4' >Weekend House</option>
<option value='5' >Office / Oficina</option>
<option value='6' >Mooring</option>
<option value='7' >Bussiness Premises</option>
<option value='8' >Commercial Building</option>
</select>
<p>Price</p>
From <input type='number' id='minPrice' />
To <input type='number' id='maxPrice' />
<input type="button" onclick='doSearch()' value='Search' />
<script>
function doSearch(){
//Init data dictionary with general parameters
var data = {"current_localization_id":0,"current_localization_type":"country","price_from":0,"price_to":999999999,"operation_types":[1,2,3],"property_types":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],"currency":"ANY","filters":[]}
//Set operation type value
if( $("#operationType").val() != -1 ){
data['operation_types'] = [$("#operationType").val()];
}
// Set property type value
if( $("#propertyTypes").val() != -1 ){
data['property_types'] = [$("#propertyTypes").val()];
}
if( $("#minPrice").val() > 0 ){
data['price_from'] = $("#minPrice").val();
}
if( $("#maxPrice").val() > 0 && $("#maxPrice").val() > $("#minPrice").val() ){
data['price_to'] = $("#maxPrice").val();
}
// Send data by GET to properties result page
window.location='./properties.php?order_by=price&limit=20&order=desc&page=1&data='+JSON.stringify(data);
}
</script>
Updated over 3 years ago