Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @@<!--This example starts with ZERO fields displayed-->
- @@<!--You can also incorporate PHP/mySQL, so that it first pulls the preexisting values from the database-->
- @@<!--THIS PART GOES IN THE HEAD SECTION OF THE SAME HTML DOCUMENT-->
- <script type="text/javascript" language="javascript">
- <!--
- function addKeyword()
- {
- var keywordObj = document.getElementById("keywordForm");
- var count = document.getElementById("keywordCount").value;
- var newObj = document.createElement("div");
- newObj.setAttribute("id", "keywordInput_" + count);
- newObj.innerHTML = "<input type='text' name='keyword[" + count + "]' /> " +
- " <input type='button' value='Delete' onClick='delKeyword(" + count + ")' />";
- keywordObj.appendChild(newObj);
- count++;
- document.getElementById("keywordCount").value = count;
- }
- function delKeyword(i)
- {
- var div = document.getElementById("keywordForm");
- var delDiv = document.getElementById("keywordInput_" + i);
- div.removeChild(delDiv);
- }
- -->
- </script>
- @@<!--WHEREVER YOU WANT THE BUTTON IN THE BODY OF THE HTML DOCUMENT, USE THIS LINE-->
- <div id="keywordForm">
- </div>
- <input type="hidden" id="keywordCount" value="0" />
- <input type="button" value="Add" onClick="addKeyword();" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement