Utklippstavle

Legg inn en helt ny kode

Valgmuligheter

DavidS sendte inn denne html4strict-koden 24.02.2010 kl. 21:32.

  1. <?php
  2. header ('Content-type:text/html;charset=UTF-8');
  3. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  5.  
  6. <title>Postal</title>
  7. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  8. <script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>
  9. <script type="text/javascript">
  10.  
  11. $(function() {
  12. $.ajaxSetup({ scriptCharset: "utf-8" , contentType: "application/json; charset=utf-8"});
  13.  
  14. $('#zip').keyup (function () {
  15.  
  16. if ($(this).val().length) {
  17. $.ajax({
  18. type: "GET",
  19. url: "get_postal.php",
  20. contentType: "application/json; charset=utf-8",
  21. dataType: "json",
  22. data: $('form').serialize(),
  23. success: function(data) {
  24. $('#info').html ('Fylke: ' + data.fylke + '<br />Kommune: ' + data.kommune + '<br />Poststed: ' + data.poststed + '<br />Postnummer: ' + data.zip + '<br /><a href="http://maps.google.com/?q=' + data.lat + ',' + data.lon + '">Google Maps</a>');
  25. }
  26. });
  27. }
  28. });
  29. });
  30. </script>
  31.  
  32. body {
  33. font-family:sans-serif;
  34. font-size:0.9em;
  35. line-height:2em
  36. }
  37.  
  38. label {
  39. display:inline-block;
  40. width:155px;
  41. }
  42.  
  43. input {
  44. text-transform:uppercase;
  45. }
  46. </style>
  47. </head>
  48.  
  49.  
  50. <h1>Informasjon om et postnummer</h1>
  51.  
  52. <form method="post" action="">
  53. <label for="zip">Postnummer eller -sted: </label><input type="text" name="q" id="zip" />
  54. </p>
  55. </form>
  56.  
  57. <p id="info"> </p>
  58. </body>

Tilbake til toppen ^

Emneord (tags): postal, ajax, jquery, postnummer