Hello,
I am looking for a way to add informative text to a search box, i.e. a text that is shown there by default and disappears when cursor is put there.
I have located the following line in template-functions.php:
`" id="search_input" size="10" />`
And I've added the following code to it:
`onfocus="if(this.value=='Start search here') this.value = ''" onblur="if(this.value=='') this.value = 'Start search here'"`
However, this would not show the "Start search here" text when a pages has just loaded, and you have to put cursor in search box for the text to start showing.
Does anyone have any ideas how to further modify the input line, so the "Start search here" text would be show all the time without having to click search box first?
Thank you!
Comments
http://blog.js-development.com
Where in the input field there is "Search..." text. I took a look at source of this site and it looks like I will need to modify the core, as I cannot see how to implement this with ZP's function printSearchForm.
If you really need to modify the function itself, copy it, rename it and use it as a theme custom function (see the theming tutorial about that) instead of hacking.
http://plugins.jquery.com/project/default-text
From what I've gathered so far (I am quite new to JS and haven't dealt with jQuery), this example code should work just by including it in the body:
`
$('input').defaultText({ defText: 'Bob' });
`
And of course there is in the head:
`
/js/jquery.defaultText.js">
`
But this did not produce any result for me... Will play with it more tomorrow. And thank you for the suggestion!
It's just a jQuery snippet found on the internet.
`
//
`
Thank you very much for sharing the code!
Change both instances of `'Start search here'` to `'<?php if ($searchwords) echo 'Search more...'; else echo 'Search starts here'; ?>'`
Of course this presumes that your them has setup the `$searchwords` variable. Not all themes do this.
<link removed by admin>