def setpnumber_function(postnrid, poststedid):
    """Event handler to load poststed from postnr, through an ajax call."""
    return (
        """
        var setpnumber = function () {
          var jdoc = loadJSONDoc('http://cache.norsktest.no/ajax/poststed/' + $('%s').value + '/');
          jdoc.addCallback(function (result) {
             if (result != "")
                $('%s').value = result;
          });
        }"""
         % (postnrid, poststedid))
