Post by MrConn » 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!)

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>
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?
Last edited by i2Paq on Wed Apr 14, 2010 4:48 pm, edited 1 time in total.
Reason: No bumping without new info.

Image
Nemmelig.no - Billige Gadgets!


Active Member

Posts

Joined
Tue Mar 23, 2010 8:08 am
Who is online

Users browsing this forum: No registered users and 5 guests