"enter part number/keyword" search field

Has anyone managed to put writing in the search field of the website just to instruct customers what they can enter in there? I would ideally like it to read Enter Part Number/Keyword and then have that disappear when the field is entered in to…Any help appreciated.

I was looking into the same thing and found this But dont know where to add it to try.



JOhn



Most blog templates come with search forms that have no text inside the input area. While this standard solution is fine, you might want to personalize your search form by adding a default text to it.



The text can help readers to identify the search area more easily, encourage them to use the search function or even clarify the searching process for non-experienced users. Here are some examples of texts that you can include on your box:



* Search

* Search here

* Search this blog

* To search, type and hit enter



Now lets clarify how to place the text inside the search form. The first thing you need to locate is the the search form code. WordPress users should be able to find it within the header.php or sidebar.php files, depending on where your search box is located. Once you find the code look for the a line similar to this one:







Now you will need to add three new arguments inside that line:



* value=”Text to be displayed here”

* onfocus=”if(this.value==this.defaultValue)this.value=”;”

* onblur=”if(this.value==”)this.value=this.defaultValue;”



The last two arguments make sure that the text you inserted will disappear once the user clicks on the input area, and also that it will reappear if the user clicks somewhere else. The final line of code will look like this:







If you want to add the text in the search box you need to:



In skins/your-skin/customer/common_templates/search.tpl



Change:






To:






Just change the Keyword or Item # to what ever you want.



Hope that helps,



Brandon

Thanks Brandon



John

Brandon your a gem, thank you for that.

the initial value “keyword or item” should be replaced by the value entered in the search.



If the customer input “phones” the new page results should have “phones” in the input field. the initial value is not longer needed.



Anyway to make it dynamic as is by default?



I’m reading about this, hope I"ll find a solution.

[quote name='colortone' timestamp='1305434193' post='112302']

the initial value “keyword or item” should be replaced by the value entered in the search.



If the customer input “phones” the new page results should have “phones” in the input field. the initial value is not longer needed.



Anyway to make it dynamic as is by default?



I'm reading about this, hope I"ll find a solution.

[/quote]



Yes, you can accomplish this quite easily.



My mod takes Brandon's one step further. His works great on the initial page load, but if you typed something and click “Search”, the resulting page would still show “Keyword or Item #” in the search box.



To accomplish what you are asking (retaining what you typed into the search box upon results display), you need to override the input field's default value. Just add the Java Script line immediately after the search box input field.



Works like a charm!






{if $search.q != ""}{/if}

[quote name='mxsystems' timestamp='1314115732' post='120148']

Just add the Java Script line immediately after the search box input field.

[/quote]



Hi, thanks for the tip. I got it working this way from a programmer who help me on this.It gets the same results. What is good on this one, is that the value is kept on search results, but it resets when you move to other page.


{if $search.q}

{else}

{/if}

[font=“Verdana”]Really good idea.



Nice work @ Colortone.



Knowing what you’ve searched for (when you come back to a page) is useful, and being able to modify that search is even more helpful! :)[/font]