Created
January 11, 2019 13:27
-
-
Save shimo164/7d31d5e5e863f7054d8bb916303dd4aa to your computer and use it in GitHub Desktop.
By clicking button, a form is added
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| </head> | |
| <body> | |
| <script> | |
| function add() | |
| { | |
| var i = document.getElementById("count").value | |
| console.log(i); | |
| var div_element = document.createElement("div"); | |
| div_element.innerHTML = '<form name="MyForm'+i+'">' | |
| +'a'+i+' <input type="text" id="a'+i+'" name="a'+i+'" value="MyForm_a'+i+'"><br>' | |
| +'b'+i+' <input type="text" id="b'+i+'" name="b'+i+'" value="MyForm_b'+i+'"><br>' | |
| +'c'+i+' <input type="text" id="c'+i+'" name="c'+i+'" value="MyForm_c'+i+'"><br>' | |
| +'</form><br>'; | |
| var parent_object = document.getElementById("id1"); | |
| parent_object.appendChild(div_element); | |
| document.getElementById("count").value = Number(i)+1; | |
| } | |
| </script> | |
| <div> | |
| <button onclick="add();">add</button> | |
| <input type="hidden" id="count" value="1"> | |
| </div> | |
| <div id="id1"></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment