There is a different search section for mobile devices and the ids have been changed to not to conflict. Below is the script used.
<scriptype="text/javascript">
$(document).ready(function() {
function cityChange()
{
//alert("City change triggred");
var city = $('#CityId option:selected').val();
return city;
}
$('#CityId').change(function(e) {
//alert("In City change");
var city = cityChange();
var dataString = 'city=' + city;
var l = window.location;
var base_url = l.protocol + "//" + l.host + "/" + l.pathname.split('/')[1];
var newBase_url = l.protocol + "//" + l.host + "/" + l.pathname.split('/')[1];
var pathArray = l.pathname.split( '/' );
if(pathArray[1] == "city"){
//If block for city modules. This section is not used in Master
newBase_url += "/city/" + city;
for ( i = 2; i < pathArray.length - 1; i++ ) {// Initial count 2 for production 3 for localhost
newBase_url += "/" + pathArray[i];
}
}else if(pathArray[1] == "listing"){
//Else block for Listing modules
newBase_url += "/" + city;
for ( i = 2; i < listingPathArray.length; i++ ) {// Initial count 2 for production 3 for localhost
newBase_url += "/" + listingPathArray[i];
}
}else if(pathArray.length == 2){// Initial count 2 for production 3 for localhost
newBase_url = base_url;
}else{
//Else block for Categor & Segment modules. This section is not used in Master
newBase_url += "/" + city;
for ( i = 2; i < pathArray.length; i++ ) {// Initial count 2 for production 3 for localhost
newBase_url += "/" + pathArray[i];
}
}
$('#newurl').val(newBase_url);
var sesReq = base_url+"/setCitySess.php";
$.ajax({
type: "POST",
url: sesReq,
data: dataString,
dataType: 'json',
cache: false,
success: function(response) {
var newBase_url = $('#newurl').val();
window.location.href=newBase_url;
}
});
return false;
});
});
</script>