X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Inserting an initial value in to the search box (https://forum.x-cart.com/showthread.php?t=60882)

sparrowdog 09-14-2011 12:16 AM

Inserting an initial value in to the search box
 
I'm doing an artwork overhaul on a 4.1.6 site and I want to set a word as the initial value in the search box.

In straight HTML I would use value="blah blah", but the value is already set in the x-cart box as value="{$search_prefilled.substring|escape}"

How can I go about getting the word 'Search' to appear as an initial value in the search box without disturbing what x-cart as in there already?

carlisleglass 09-14-2011 04:46 AM

Re: Inserting an initial value in to the search box
 
try ...

Code:

<input type="text" name="posted_data[substring]" {if $search_prefilled.substring|escape}value="{$search_prefilled.substring|escape}"{else}value="Enter search term"  autocomplete="off" onKeyUp="ajax_showOptions(this,'getProduct',event)" onfocus="if(this.value=='Enter search term') this.value='';" onblur="if(this.value=='') this.value=this.defaultValue;"{/if} />

totaltec 09-14-2011 06:48 AM

Re: Inserting an initial value in to the search box
 
An underused html attribute that works in modern browsers is placeholder.

Use it like this <input type="text" placeholder="blah, blah">.

I used to do it with javascript, but this works great.

sparrowdog 09-14-2011 11:46 PM

Re: Inserting an initial value in to the search box
 
Thanks Darren. The javascript worked a charm.


All times are GMT -8. The time now is 09:56 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.