Create Html Module and add Zip Code box in it.
Select the Html Module from the list of modules. Add to Content Pane
Click on Edit Content from the Edit action menu of module container
Add Html for ZipCode box
Open Portal's default.ascx file and write the below code inside script.
Using the below service to get the state from zipcode
api.zippopotam.us/country/postal-code
Refer http://www.zippopotam.us/ for country code.
Below example is for US country.
$("#btnZipCode").click(function () {
var val = $("#txtZipCode").val(); //Calling the service and getting the state from zipcode
var jqXHR = $.ajax({
url: 'http://api.zippopotam.us/us/' + val,
dataType: 'json',
async: false
});
var json = JSON.parse(jqXHR.responseText);
var result = json.places[0].state;
alert(result);
});
Select the Html Module from the list of modules. Add to Content Pane
Click on Edit Content from the Edit action menu of module container
Add Html for ZipCode box
Open Portal's default.ascx file and write the below code inside script.
Using the below service to get the state from zipcode
api.zippopotam.us/country/postal-code
Refer http://www.zippopotam.us/ for country code.
Below example is for US country.
$("#btnZipCode").click(function () {
var val = $("#txtZipCode").val(); //Calling the service and getting the state from zipcode
var jqXHR = $.ajax({
url: 'http://api.zippopotam.us/us/' + val,
dataType: 'json',
async: false
});
var json = JSON.parse(jqXHR.responseText);
var result = json.places[0].state;
alert(result);
});






No comments:
Post a Comment