Postal no. -> City (Howto?)
Posted: Wed Apr 14, 2010 12:41 am
Hi,
The Norwegian postalservice has got a great little app that I would like to implant into my opencart-installation...
This code automatically fills out City based on the postalcode (Norwegian only!)
The code can be seen here
But as you can see the code only gives the city ("postnummerResult") out as a span... How can I get the output in a text-field?
The Norwegian postalservice has got a great little app that I would like to implant into my opencart-installation...
This code automatically fills out City based on the postalcode (Norwegian only!)
Code: Select all
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function() {
inputField = $('#postnummerInput');
outputElement = $('#postnummerResult');
inputField.keyup(function() {
if (inputField.val().length == 4) {
$.getJSON('http://fraktguide.bring.no/fraktguide/postalCode.json?pnr='+ inputField.val() +'&callback=?',
function(data){
outputElement.text(data.result);
});
}
else {
outputElement.text('');
}
});
});
</script>
<form>
<input type="text" id="postnummerInput" style="width: 4em;"/> <span id="postnummerResult"> </span>
</form>
But as you can see the code only gives the city ("postnummerResult") out as a span... How can I get the output in a text-field?