Hola, necesitamos ayuda de alguien para añadir los códigos postales de ciudades de Londres a un formulario en el siguiente link:
https://sotosolutions.co.uk/find-a-boiler/ deben pulsar en Start Now > Gas > y seguir todas las opciones como deseen marcando Yes donde lo pregunte, al final aparecerá un campo de añadir Codigo postal, esos códigos postales son los que hay que vincular, no hay bases de datos, al parecer estaba consultando una API, este es el js del formulario:
var house_details = {};
var current_step = "#start-section";
function ScrollToTop(){
if (
navigator.userAgent.match(/(iPod|iPhone|iPad|Android)/)) {
window.scrollTo(0,200) // first value for left offset, second value for top offset
}
}
function CheckPostCode(){
jQuery('#PostcodeError').hide();
jQuery('#PostCodeNotServicedError').hide();
var postcode = jQuery('#postcode_textbox').val();
if(postcode == ""){
jQuery('#PostcodeError').show();
}
else{
var filtered_postcode = postcode.replace(/\s/g, '').toUpperCase();
house_details["filtered_postcode"] = filtered_postcode;
Cookies.set('postcode', filtered_postcode);
var region = null;
jQuery.ajax("https://api.postcodes.io/postcodes/" + filtered_postcode)
.done(function(data) {
region =
data.result.region;
CheckValidRegion(region);
})
.fail(function() {
jQuery('#PostcodeError').show();
});
}
}
function CheckValidRegion(region){
if(region == "South East"){
var querystring = "
https://www.sotosolutions.co.uk/boilers/";
var boiler_type = "";
if (house_details["boiler_type"] == "combi-boiler"){
boiler_type = "combi-boiler";
}
else if (house_details["boiler_type"] == "system-boiler"){
boiler_type = "system-boiler";
}
else if (house_details["boiler_type"] == "conventional-boiler"){
boiler_type = "conventional-boiler";
}
if ("convert_combi" in house_details){
if (house_details["convert_combi"] == "yes"){
boiler_type = "combi-boiler";
}
}
var convertcombi = "";
var convertfromconventional = "";
//If already a combi, then don't add convert
if (house_details["boiler_type"] == "combi-boiler"){
convertcombi = "0";
}
//Else if final convert type is combi-boiler, but not originally, then set convert flag to 1
else {
if (boiler_type == "combi-boiler"){
convertcombi = "1";
//Now also check if from conventional boiler so need to add extra tag
if (house_details["boiler_type"] == "conventional-boiler"){
convertfromconventional = "1";
}
}
else {
convertcombi = "0";
}
}
var newboilerlocation = 0;
if ( house_details["newboilersameplace"] == "no" ){
newboilerlocation = house_details["newboilerlocation"];
}
var bedroom = house_details["bedroom"].replace("bedrooms-", "");
var bathroom = house_details["bathroom"].replace("bathrooms-", "");
var roof = house_details["flue_on"] == "roof" ? 1 : 0;
var filtered_postcode = house_details["filtered_postcode"];
var filter = "?filter_bd=" + bedroom + "&filter_bth=" + bathroom + "&convertcombi=" + convertcombi + "&roof=" + roof + "&newboilerlocation=" + newboilerlocation;
if (convertfromconventional == "1") {
filter += "&convertfromconventional=" + convertfromconventional;
}
querystring = querystring + boiler_type + "/" + filter;
var smartlook = "
https://sotosolutions.co.uk/survey/SmartLook.php" + filter + "&postcode=" + filtered_postcode;
jQuery.ajax(smartlook)
.done(function(data) {
});
window.location.href=querystring;
}
else{
jQuery('#PostCodeNotServicedError').show();
}
}
jQuery(document).ready(function() {
jQuery(document).on('click','#bq-start',function(e){
e.preventDefault();
jQuery('#start-section').hide();
jQuery('#step-fuel-type').data('backstep', '#start-section');
current_step = "#step-fuel-type";
jQuery('#step-fuel-type').show();
jQuery('.backbutton').show();
ScrollToTop();
});
jQuery('.fuel-kind').on('click',function(e){
e.preventDefault();
jQuery('.fuel-kind').removeClass('active');
jQuery(this).addClass('active');
var fuel_type_selected =
this.id;
if (typeof fuel_type_selected != 'undefined'){
house_details["fuel_type"] = fuel_type_selected;
Cookies.set('fuel_type', fuel_type_selected);
jQuery('#step-fuel-type').hide();
if (fuel_type_selected == 'gas'){
jQuery('#step-gas-boiler-type').data('backstep', '#step-fuel-type');
current_step = "#step-gas-boiler-type";
jQuery('#step-gas-boiler-type').show();
}
else{
jQuery('#step-give-ring').data('backstep', '#step-fuel-type');
current_step = "#step-give-ring";
jQuery('#step-give-ring').show();
}
}
ScrollToTop();
});
jQuery('.boiler-kind').on('click',function(e){
e.preventDefault();
jQuery('.boiler-kind').removeClass('active');
jQuery(this).addClass('active');
var boiler_type_selected =
this.id;
if(typeof boiler_type_selected != 'undefined'){
house_details["boiler_type"] = boiler_type_selected;
Cookies.set('boiler_type', boiler_type_selected);
jQuery('#step-gas-boiler-type').hide();
if(boiler_type_selected == "combi-boiler"){
jQuery('#step-current-boiler-location').data('backstep', '#step-gas-boiler-type');
current_step = "#step-current-boiler-location";
jQuery('#step-current-boiler-location').show();
}else{
jQuery('#step-convert-combi').data('backstep', '#step-gas-boiler-type');
current_step = "#step-convert-combi";
jQuery('#step-convert-combi').show();
}
}
ScrollToTop();
});
jQuery('.convert-combi').on('click',function(e){
e.preventDefault();
jQuery('.convert-combi').removeClass('active');
jQuery(this).addClass('active');
var convert_combi =
this.id;
if(typeof convert_combi != 'undefined'){
house_details["convert_combi"] = convert_combi;
Cookies.set('convert_combi', convert_combi);
jQuery('#step-convert-combi').hide();
if(convert_combi == "yes"){
jQuery('#step-cold-tap').data('backstep', '#step-convert-combi');
current_step = "#step-cold-tap";
jQuery('#step-cold-tap').show();
}else{
if(house_details["boiler_type"] == "back-boiler"){
jQuery('#step-give-ring').data('backstep', '#step-convert-combi');
current_step = "#step-give-ring";
jQuery('#step-give-ring').show();
}
else{
jQuery('#step-current-boiler-location').data('backstep', '#step-convert-combi');
current_step = "#step-current-boiler-location";
jQuery('#step-current-boiler-location').show();
}
}
}
ScrollToTop();
});
jQuery('.cold-tap').on('click',function(e){
e.preventDefault();
jQuery('.cold-tap').removeClass('active');
jQuery(this).addClass('active');
var coldtap =
this.id;
if(typeof coldtap != 'undefined'){
house_details["coldtap"] = coldtap;
Cookies.set('coldtap', coldtap);
jQuery('#step-cold-tap').hide();
if(coldtap != "slow"){
jQuery('#step-current-boiler-location').data('backstep', '#step-cold-tap');
current_step = "#step-current-boiler-location";
jQuery('#step-current-boiler-location').show();
}else{
jQuery('#step-give-ring').data('backstep', '#step-cold-tap');
current_step = "#step-give-ring";
jQuery('#step-give-ring').show();
}
}
ScrollToTop();
});
jQuery('.current-boiler-location').on('click',function(e){
e.preventDefault();
jQuery('.current-boiler-location').removeClass('active');
jQuery(this).addClass('active');
var currentboilerlocation =
this.id;
if(typeof currentboilerlocation != 'undefined'){
house_details["currentboilerlocation"] = currentboilerlocation;
Cookies.set('currentboilerlocation', currentboilerlocation);
jQuery('#step-current-boiler-location').hide();
jQuery('#step-new-boiler-same-place').data('backstep', '#step-current-boiler-location');
current_step = "#step-new-boiler-same-place";
jQuery('#step-new-boiler-same-place').show();
}
ScrollToTop();
});
jQuery('.new-boiler-same-place').on('click',function(e){
e.preventDefault();
jQuery('.new-boiler-same-place').removeClass('active');
jQuery(this).addClass('active');
var newboilersameplace =
this.id;
if(typeof newboilersameplace != 'undefined'){
if(newboilersameplace == 'new-boiler-yes'){
newboilersameplace = 'yes';
}
else{
newboilersameplace = 'no';
}
house_details["newboilersameplace"] = newboilersameplace;
Cookies.set('newboilersameplace', newboilersameplace);
jQuery('#step-new-boiler-same-place').hide();
if(newboilersameplace == "yes"){
jQuery('#step-home-type').data('backstep', '#step-new-boiler-same-place');
current_step = "#step-home-type";
jQuery('#step-home-type').show();
}else{
jQuery('#step-is-outside-wall').data('backstep', '#step-new-boiler-same-place');
current_step = "#step-is-outside-wall";
jQuery('#step-is-outside-wall').show();
}
}
ScrollToTop();
});
jQuery('.is-outside-wall').on('click',function(e){
e.preventDefault();
jQuery('.is-outside-wall').removeClass('active');
jQuery(this).addClass('active');
var isoutsidewall =
this.id;
if(typeof isoutsidewall != 'undefined'){
house_details["isoutsidewall"] = isoutsidewall;
Cookies.set('isoutsidewall', isoutsidewall);
jQuery('#step-is-outside-wall').hide();
if(isoutsidewall == "outside-wall-yes"){
jQuery('#step-new-boiler-location').data('backstep', '#step-is-outside-wall');
current_step = "#step-new-boiler-location";
//Change data of current location:
//var current_location_id = house_details["currentboilerlocation"];
//jQuery('#step-new-boiler-location ' + '#' + current_location_id).hide();
//jQuery('#step-new-boiler-location ' + '#' + current_location_id).attr("id", "same-room");
//jQuery('#step-new-boiler-location ' + '#same-room span.et_pb_image_wrap img').attr("src", "
https://www.sotosolutions.co.uk/wp-content/uploads/same-room.png");
//jQuery('#step-new-boiler-location ' + '#same-room h1.et_pb_module_header').text("Same Room");
jQuery('#step-new-boiler-location').show();
}
else{
jQuery('#step-give-ring').data('backstep', '#step-is-outside-wall');
current_step = "#step-give-ring";
jQuery('#step-give-ring').show();
}
}
ScrollToTop();
});
jQuery('.new-boiler-location').on('click',function(e){
e.preventDefault();
jQuery('.new-boiler-location').removeClass('active');
jQuery(this).addClass('active');
var newboilerlocation =
this.id;
if(typeof newboilerlocation != 'undefined'){
house_details["newboilerlocation"] = newboilerlocation;
Cookies.set('newboilerlocation', newboilerlocation);
jQuery('#step-new-boiler-location').hide();
if(newboilerlocation != "other"){
jQuery('#step-home-type').data('backstep', '#step-new-boiler-location');
current_step = "#step-home-type";
jQuery('#step-home-type').show();
}
else{
jQuery('#step-give-ring').data('backstep', '#step-new-boiler-location');
current_step = "#step-give-ring";
jQuery('#step-give-ring').show();
}
}
ScrollToTop();
});
jQuery('.home-kind').on('click',function(e){
e.preventDefault();
jQuery('.home-kind').removeClass('active');
jQuery(this).addClass('active');
var homekind =
this.id;
if(typeof homekind != 'undefined'){
house_details["homekind"] = homekind;
Cookies.set('homekind', homekind);
jQuery('#step-home-type').hide();
jQuery('#step-bedrooms').data('backstep', '#step-home-type');
current_step = "#step-bedrooms";
jQuery('#step-bedrooms').show();
}
ScrollToTop();
});
jQuery('.bedroom-number').on('click',function(e){
e.preventDefault();
jQuery('.bedroom-number').removeClass('active');
jQuery(this).addClass('active');
var bedroom_number =
this.id;
if(typeof bedroom_number != 'undefined'){
house_details["bedroom"] = bedroom_number;
Cookies.set('bedroom', bedroom_number);
jQuery('#step-bedrooms').hide();
jQuery('#step-bathrooms').data('backstep', '#step-bedrooms');
current_step = "#step-bathrooms";
jQuery('#step-bathrooms').show();
}
ScrollToTop();
});
jQuery('.bathroom-number').on('click',function(e){
e.preventDefault();
jQuery('.bathroom-number').removeClass('active');
jQuery(this).addClass('active');
var bathroom_number =
this.id;
if(typeof bathroom_number != 'undefined'){
house_details["bathroom"] = bathroom_number;
Cookies.set('bathroom', bathroom_number);
jQuery('#step-bathrooms').hide();
jQuery('#step-flue-on').data('backstep', '#step-bathrooms');
current_step = "#step-flue-on";
jQuery('#step-flue-on').show();
}
ScrollToTop();
});
jQuery('.flue-on').on('click',function(e){
e.preventDefault();
jQuery('.flue-on').removeClass('active');
jQuery(this).addClass('active');
var flue_on =
this.id;
if(typeof flue_on != 'undefined'){
house_details["flue_on"] = flue_on;
Cookies.set('flue_on', flue_on);
jQuery('#step-flue-on').hide();
if(flue_on == 'roof'){
jQuery('#step-roof-type').data('backstep', '#step-flue-on');
current_step = "#step-roof-type";
jQuery('#step-roof-type').show();
}
else{
jQuery('#step-enter-postcode').data('backstep', '#step-flue-on');
current_step = "#step-enter-postcode";
jQuery('#step-enter-postcode').show();
}
}
ScrollToTop();
});
jQuery('.roof-type').on('click',function(e){
e.preventDefault();
jQuery('.roof-type').removeClass('active');
jQuery(this).addClass('active');
var roof_type =
this.id;
if(typeof roof_type != 'undefined'){
house_details["roof_type"] = roof_type;
Cookies.set('roof_type', roof_type);
jQuery('#step-roof-type').hide();
jQuery('#step-enter-postcode').data('backstep', '#step-roof-type');
current_step = "#step-enter-postcode";
jQuery('#step-enter-postcode').show();
}
ScrollToTop();
});
jQuery('.postcode_button').on('click',function(e){
e.preventDefault();
CheckPostCode();
ScrollToTop();
});
jQuery('#postcode_form').on('submit',function(e){
e.preventDefault();
CheckPostCode();
ScrollToTop();
});
jQuery('.backbuttonicon').on('click', function(e){
e.preventDefault();
var backstep = jQuery(current_step).data('backstep');
if(backstep == "#start-section"){
jQuery(".backbutton").hide();
}
jQuery(current_step).hide();
current_step = backstep;
jQuery(backstep).show();
});
});
Saludos.
Categoría: Programación y Tecnología
Subcategoría: Wordpress
¿Cuál es el alcance del proyecto?: Instalación de plugin
¿Es un proyecto o una posición?: Un proyecto
Actualmente tengo: Tengo las especificaciones
Disponibilidad requerida: Según se necesite
Integraciones de API: Otros (Otras APIs)