Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. <script type="text/javascript">
  2. function ModifyPlaceHolder1 () {
  3. var input = document.getElementById ("MyQuery");
  4. input.placeholder = "Search books e.g. Harry Potter";
  5. }
  6. function ModifyPlaceHolder2 () {
  7. var input = document.getElementById ("MyQuery");
  8. input.placeholder = "Search journals e.g. New Scientist";
  9. }
  10. </script>
  11.  
  12.  
  13. <input type="text" id="MyQuery" placeholder="Search resources" name="q" />
  14. <input type="radio" value="" id="All" name="s.cmd" checked="checked" />
  15. <label for="All">All</label>
  16. <input type="radio" onclick="ModifyPlaceHolder1 ()" value="" id="Books" name="s.cmd" checked="checked" />
  17. <label for="Books">Books</label>
  18. <input type="radio" onclick="ModifyPlaceHolder2 ()" value="" id="Journals" name="s.cmd" checked="checked" />
  19. <label for="Journals">Journals</label>
  20.  
  21. <input type="text" id="MyQuery" placeholder="Search resources" name="q" />
  22. <input type="radio" value="" id="All" name="s.cmd" checked="checked" />
  23. <label for="All">All</label>
  24. <input type="radio" value="" id="Books" name="s.cmd" checked="checked" />
  25. <label for="Books">Books</label>
  26. <input type="radio" value="" id="Journals" name="s.cmd" checked="checked" />
  27. <label for="Journals">Journals</label>
  28.  
  29. var books = document.getElementById("Books");
  30. var journals = document.getElementById("Journals");
  31. var input = document.getElementById("MyQuery");
  32.  
  33. books.onclick = function() {
  34. input.placeholder = "Search books e.g. Harry Potter";
  35. }
  36.  
  37. journals.onclick = function() {
  38. input.placeholder = "Search journals e.g. New Scientist";
  39. }
  40.  
  41. <script>
  42. function ModifyPlaceHolder(element) {
  43. var data = {
  44. All: 'Search resources',
  45. Books: 'Search books e.g. Harry Potter',
  46. Journals: 'Search journals e.g. New Scientist'
  47. };
  48. var input = element.form.MyQuery;
  49. input.placeholder = data[element.id];
  50. }
  51.  
  52. </script>
  53.  
  54. <form>
  55. <input type="text" id="MyQuery" placeholder="Search resources" name="q">
  56. <label for="All"><input type="radio" onclick="ModifyPlaceHolder(this)" id="All" name="s.cmd" checked> All</label>
  57. <label for="Books"><input type="radio" onclick="ModifyPlaceHolder(this)" id="Books" name="s.cmd"> Books</label>
  58. <label for="Journals"><input type="radio" onclick="ModifyPlaceHolder(this)" id="Journals" name="s.cmd"> Journals</label>
  59. </form>
  60.  
  61. `<script>
  62. function ModifyPlaceHolder(element) {
  63. var data = {
  64. All: 'Search resources',
  65. Books: 'Search books e.g. Harry Potter',
  66. Journals: 'Search journals e.g. New Scientist'
  67. };
  68. var input = document.getElementById("MyQuery");
  69. input.placeholder = data[element.id];
  70. }
  71. </script>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement