Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title>Untitled Page</title>
- <script type="text/javascript">
- var counter = 0;
- function moreFields()
- {
- counter++;
- var newFields = document.getElementById('readroot').cloneNode(true);
- newFields.id = '';
- newFields.style.display = 'block';
- var newField = newFields.childNodes;
- for (var i=0;i<newField.length;i++)
- {
- var theName = newField[i].name;
- if (theName)
- newField[i].name = theName + counter;
- }
- var insertHere = document.getElementById('writeroot');
- insertHere.parentNode.insertBefore(newFields,insertHere);
- }
- window.onload = moreFields;
- </script>
- </head>
- <body>
- <form method="post" id="ciao" action="\result.php">
- <div id="readroot" style="display: none">
- <div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
- <label for="form-nome">Nome</label>
- <input type="text" name="nome" class="form-control field" id="form-nome" />
- </div>
- <div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
- <label for="form-cognome">Cognome</label>
- <input type="text" name="cognome" class="form-control field" id="form-cognome" />
- </div>
- <div class="col-xs-12 col-sm-6 col-md-6 col-lg-3">
- <label for="form-datanascita">Data di nascita</label>
- <input type="text" name="datanascita" placeholder="GG/MM/AAAA" class="form-control field" id="form-datanascita" />
- </div>
- </div>
- <span id="writeroot"></span>
- <input type="button" id="btnMore" onclick="moreFields();" value="Give me more fields!" />
- <input type="submit" value="Send form" />
- </form>
- <!--Javascript-->
- <script type="text/javascript">
- $(document).ready(function() {
- $("#ciao").submit(function(){
- var querystring = $('#ciao').serialize();
- $.ajax({
- url: '/result.php',
- type: "POST",
- data: querystring,
- success: function(data) {
- $("div#result2").html(data);
- }
- });
- return false;
- });
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement