2
I’m riding a website, and on the home page I created a select
for states and cities, the problem is that the home page of the website is catching up too.
Does anyone know how I can do this select
without halting the website? Or maybe do it another way?
The website link is http://www.simplemed.com.br
<?php
ItemForm::region_select(osc_get_regions(osc_user_region()), osc_user()); ?> </div>
</div>
<div class="col-md-3">
<div class="cell selector">
<!--------------City-------------------->
<?php ItemForm::city_select(osc_get_cities(osc_user_region()), osc_user()); ?>
<!--------------City End-------------------->
</div>
</div>
<div class="col-md-2">
<div class="cell reset-padding">
<button class="btn btn-success btn_search">
<?php _e( "Search", 'osclasswizards');?> </button>
</div>
</div>
</div>
</div>
<div id="message-seach"></div>
</div>
</div>
</form>
<script type="text/javascript">
$(document).ready(function() {
$("#regionId").on("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 != '') {
$("#cityId").attr('disabled', false);
$.ajax({
type: "POST",
url: url,
dataType: 'json',
success: function(data) {
var length = data.length;
if (length > 0) {
result = '<option selected value=""><?php _e("Select a city..."); ?></option>';
for (key in data) {
result = '<option value="'
data[key].pk_i_id '">'
data[key].s_name '</option>';
}
$("#city").before('<select name="cityId" id="cityId" ></select>');
$("#city").remove();
} else {
result = '<option value=""><?php _e('
No results ') ?></option>';
$("#cityId").before('<input type="text" name="city" id="city" />');
$("#cityId").remove();
}
$("#cityId").html(result);
}
});
} else {
$("#cityId").attr('disabled', true);
}
});
if ($("#regionId").attr('value') == "") {
$("#cityId").attr('disabled', true);
}
});
</script>
Post your code, as you are doing, whether you are searching all at once or as selected...
– Maicon Carraro
welcome to the Portuguese stackoverflow, please read the [Ask], it would be interesting to put the existing code or link to your page
– Pedro Sanção
@Victor, you’ve been around Pagespeed Insights on your website?
– user25930
@ctgPi, I don’t know Pagespeed Insights
– Victor Mendes
You can put the rendered HTML?
– Sergio
Just a few days ago @Sergio helped me implement this script: http://jsfiddle.net/w938st7q/2/ Fiddle only has two states, but you can download here.
– gustavox
http://answall.com/questions/99107/listar-estados-cidades-e-bairros-em-formul%C3%A1rio-de-cadastro/99133#99133
– marcusagm