Posted By

hotdiggity on 06/02/10


Tagged

javascript forms autofill


Versions (?)

Autofill form


 / Published in: JavaScript
 

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4.  
  5. <script type="text/javascript"><!--
  6. function autofill(form_number)
  7. {
  8. document.forms[form_number].address_delivery.value = document.forms[form_number].address.value;
  9. document.forms[form_number].city_delivery.value = document.forms[form_number].city.value;
  10. document.forms[form_number].country_delivery.value = document.forms[form_number].country.value;
  11. document.forms[form_number].state_delivery.value = document.forms[form_number].state.value;
  12. document.forms[form_number].postcode_delivery.value = document.forms[form_number].postcode.value;
  13. }
  14. -->
  15. </script>
  16. </head>
  17. <body>
  18. <form>
  19. <p>Address*
  20. <input type="text" name="address" size="37">
  21. </p>
  22. <p>
  23. <label>Suburb/City*</label>
  24. <input type="text" name="city"/>
  25. </p>
  26. <p>
  27. <label>State*</label>
  28. <input type="text" name="state"/>
  29. </p>
  30. <p>
  31. <label>Country*</label>
  32. <input type="text" name="country"/>
  33. </p>
  34. <p>
  35. <label>Postcode/Zip*</label>
  36. <input type="text" name="postcode" size="7"/>
  37. </p>
  38. <p>Please enter your delivery details &#150; <a onClick="autofill(0)" href="#">Click here if same as above to autofill</a>
  39. </p>
  40. <p>
  41. <p>Address*
  42. <input type="text" name="address_delivery" size="37">
  43. </p>
  44. <p>
  45. <label>City*</label>
  46. <input type="text" name="city_delivery"/>
  47. </p>
  48. <p>
  49. <label>State*</label>
  50. <input type="text" name="state_delivery"/>
  51. </p>
  52. <p>
  53. <label>Country*</label>
  54. <input type="text" name="country_delivery"/>
  55. </p>
  56. <p>
  57. <label>Postcode/Zip*</label>
  58. <input type="text" name="postcode_delivery" size="7"/>
  59. </p>
  60. </form>
  61. </body>
  62. </html>

Report this snippet  

You need to login to post a comment.