Hi guys how do i change the location javascript to let work this on the search bar?
This code i use on the item post and works great can i change this for the search bar?
<?php itemform::location_javascript(); ?>
This code i find in the sidebar search
<script>
$(document).ready(function() {
$("#sCountry").live("change",function(){
var pk_c_code = $(this).val();
<?php if($path=="admin") { ?>
var url = '<?php echo osc_admin_base_url(true)."?page=ajax&action=regions&countryId="; ?>' + pk_c_code;
<?php } else { ?>
var url = '<?php echo osc_base_url(true)."?page=ajax&action=regions&countryId="; ?>' + pk_c_code;
<?php }; ?>
var result = '';
if(pk_c_code != '') {
$("#sRegion").show();
$.ajax({
type: "GET",
url: url,
dataType: 'json',
success: function(data){
var length = data.length;
if(length > 0) {
result += '<option selected value=""><?php _e('Select a Province...', 'ctg_housing'); ?></option>';
for(key in data) {
result += '<option value="' + data[key].pk_i_id + '">' + data[key].s_name + '</option>';
}
$("#region").before('<select name="sRegion" id="sRegion" ></select>');
$("#region").remove();
$("#sCity").show();
} else {
result += '<option value=""><?php _e('No results', 'ctg_housing') ?></option>';
$("#sRegion").before('<input type="text" name="region" id="region" />');
$("#sRegion").remove();
}
$("#sRegion").html(result);
}
});
} else {
$("#sRegion").show();
$("#sCity").show();
}
});
if( $("#sCountry").attr('value') == "") {
$("#sRegion").show();
$("#sCity").show();
}
$("#sRegion").live("change",function(){
var pk_c_code = $(this).val();
<?php if($path=="admin") { ?>
var url = '<?php echo osc_admin_base_url(true)."?page=ajax&action=cities®ionId="; ?>' + pk_c_code;
<?php } else { ?>
var url = '<?php echo osc_base_url(true)."?page=ajax&action=cities®ionId="; ?>' + pk_c_code;
<?php }; ?>
var result = '';
if(pk_c_code != '') {
$("#sCity").show();
$.ajax({
type: "GET",
url: url,
dataType: 'json',
success: function(data){
var length = data.length;
if(length > 0) {
result += '<option selected value=""><?php _e('Select a Barangay...', 'ctg_housing'); ?></option>';
for(key in data) {
result += '<option value="' + data[key].pk_i_id + '">' + data[key].s_name + '</option>';
}
$("#city").before('<select name="sRegion" id="sRegion" ></select>');
$("#city").remove();
} else {
result += '<option value=""><?php _e('No results', 'ctg_housing') ?></option>';
$("#sCity").before('<input type="text" name="region" id="region" />');
$("#sCity").remove();
}
$("#sCity").html(result);
}
});
} else {
$("#sCity").show();
}
});
if( $("#sRegion").attr('value') == "") {
$("#sCity").show();
}
});
</script>
Thanks