Advertisement
Guest User

MichThom

a guest
Nov 26th, 2008
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. @@<!--This example starts with ZERO fields displayed-->
  2. @@<!--You can also incorporate PHP/mySQL, so that it first pulls the preexisting values from the database-->
  3.  
  4. @@<!--THIS PART GOES IN THE HEAD SECTION OF THE SAME HTML DOCUMENT-->
  5.  
  6. <script type="text/javascript" language="javascript">
  7. <!--
  8.  
  9. function addKeyword()
  10. {
  11. var keywordObj = document.getElementById("keywordForm");
  12. var count = document.getElementById("keywordCount").value;
  13. var newObj = document.createElement("div");
  14. newObj.setAttribute("id", "keywordInput_" + count);
  15. newObj.innerHTML = "<input type='text' name='keyword[" + count + "]' /> " +
  16. " <input type='button' value='Delete' onClick='delKeyword(" + count + ")' />";
  17. keywordObj.appendChild(newObj);
  18. count++;
  19. document.getElementById("keywordCount").value = count;
  20. }
  21.  
  22.  
  23. function delKeyword(i)
  24. {
  25. var div = document.getElementById("keywordForm");
  26. var delDiv = document.getElementById("keywordInput_" + i);
  27. div.removeChild(delDiv);
  28. }
  29. -->
  30. </script>
  31.  
  32.  
  33.  
  34.  
  35. @@<!--WHEREVER YOU WANT THE BUTTON IN THE BODY OF THE HTML DOCUMENT, USE THIS LINE-->
  36. <div id="keywordForm">
  37. </div>
  38. <input type="hidden" id="keywordCount" value="0" />
  39. <input type="button" value="Add" onClick="addKeyword();" />
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement