Advertisement
jumpy83

pagina1

Apr 26th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.59 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2.  
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head runat="server">
  5. <title>Untitled Page</title>
  6.  
  7. <script type="text/javascript">
  8. var counter = 0;
  9.  
  10. function moreFields()
  11. {
  12. counter++;
  13. var newFields = document.getElementById('readroot').cloneNode(true);
  14. newFields.id = '';
  15. newFields.style.display = 'block';
  16. var newField = newFields.childNodes;
  17. for (var i=0;i<newField.length;i++)
  18. {
  19. var theName = newField[i].name;
  20. if (theName)
  21. newField[i].name = theName + counter;
  22. }
  23. var insertHere = document.getElementById('writeroot');
  24. insertHere.parentNode.insertBefore(newFields,insertHere);
  25. }
  26.  
  27. window.onload = moreFields;
  28. </script>
  29. </head>
  30. <body>
  31.  
  32.  
  33. <form method="post" id="ciao" action="\result.php">
  34. <div id="readroot" style="display: none">
  35.  
  36. <div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
  37. <label for="form-nome">Nome</label>
  38. <input type="text" name="nome" class="form-control field" id="form-nome" />
  39. </div>
  40. <div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
  41. <label for="form-cognome">Cognome</label>
  42. <input type="text" name="cognome" class="form-control field" id="form-cognome" />
  43. </div>
  44. <div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
  45. <label for="form-datanascita">Data di nascita</label>
  46. <input type="text" name="datanascita" placeholder="GG/MM/AAAA" class="form-control field" id="form-datanascita" />
  47.  
  48. </div>
  49. </div>
  50. <span id="writeroot"></span>
  51.  
  52. <input type="button" id="btnMore" onclick="moreFields();" value="Give me more fields!" />
  53. <input type="submit" value="Send form" />
  54.  
  55.  
  56. </form>
  57. <!--Javascript-->
  58.  
  59. <script type="text/javascript">
  60.  
  61. $(document).ready(function() {
  62.  
  63. $("#ciao").submit(function(){
  64. var querystring = $('#ciao').serialize();
  65.  
  66. $.ajax({
  67. url: '/result.php',
  68. type: "POST",
  69. data: querystring,
  70. success: function(data) {
  71. $("div#result2").html(data);
  72. }
  73.  
  74. });
  75.  
  76. return false;
  77. });
  78.  
  79. });
  80. </script>
  81. </body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement