Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- function ModifyPlaceHolder1 () {
- var input = document.getElementById ("MyQuery");
- input.placeholder = "Search books e.g. Harry Potter";
- }
- function ModifyPlaceHolder2 () {
- var input = document.getElementById ("MyQuery");
- input.placeholder = "Search journals e.g. New Scientist";
- }
- </script>
- <input type="text" id="MyQuery" placeholder="Search resources" name="q" />
- <input type="radio" value="" id="All" name="s.cmd" checked="checked" />
- <label for="All">All</label>
- <input type="radio" onclick="ModifyPlaceHolder1 ()" value="" id="Books" name="s.cmd" checked="checked" />
- <label for="Books">Books</label>
- <input type="radio" onclick="ModifyPlaceHolder2 ()" value="" id="Journals" name="s.cmd" checked="checked" />
- <label for="Journals">Journals</label>
- <input type="text" id="MyQuery" placeholder="Search resources" name="q" />
- <input type="radio" value="" id="All" name="s.cmd" checked="checked" />
- <label for="All">All</label>
- <input type="radio" value="" id="Books" name="s.cmd" checked="checked" />
- <label for="Books">Books</label>
- <input type="radio" value="" id="Journals" name="s.cmd" checked="checked" />
- <label for="Journals">Journals</label>
- var books = document.getElementById("Books");
- var journals = document.getElementById("Journals");
- var input = document.getElementById("MyQuery");
- books.onclick = function() {
- input.placeholder = "Search books e.g. Harry Potter";
- }
- journals.onclick = function() {
- input.placeholder = "Search journals e.g. New Scientist";
- }
- <script>
- function ModifyPlaceHolder(element) {
- var data = {
- All: 'Search resources',
- Books: 'Search books e.g. Harry Potter',
- Journals: 'Search journals e.g. New Scientist'
- };
- var input = element.form.MyQuery;
- input.placeholder = data[element.id];
- }
- </script>
- <form>
- <input type="text" id="MyQuery" placeholder="Search resources" name="q">
- <label for="All"><input type="radio" onclick="ModifyPlaceHolder(this)" id="All" name="s.cmd" checked> All</label>
- <label for="Books"><input type="radio" onclick="ModifyPlaceHolder(this)" id="Books" name="s.cmd"> Books</label>
- <label for="Journals"><input type="radio" onclick="ModifyPlaceHolder(this)" id="Journals" name="s.cmd"> Journals</label>
- </form>
- `<script>
- function ModifyPlaceHolder(element) {
- var data = {
- All: 'Search resources',
- Books: 'Search books e.g. Harry Potter',
- Journals: 'Search journals e.g. New Scientist'
- };
- var input = document.getElementById("MyQuery");
- input.placeholder = data[element.id];
- }
- </script>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement