Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Inserting an initial value in to the search box

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 09-14-2011, 12:16 AM
 
sparrowdog sparrowdog is offline
 

eXpert
  
Join Date: Jan 2007
Posts: 244
 

Default 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?
__________________
Version 4.1.6 to 4.1.11
Reply With Quote
  #2  
Old 09-14-2011, 04:46 AM
  carlisleglass's Avatar 
carlisleglass carlisleglass is offline
 

eXpert
  
Join Date: Aug 2003
Location: Carlisle, UK
Posts: 316
 

Default 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} />
__________________
Darren Kierman
Carlisle Glass (http://www.carlisleglass.co.uk/)
... running X-Cart Gold 4.4.5 [unix]
Reply With Quote
  #3  
Old 09-14-2011, 06:48 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default 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.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #4  
Old 09-14-2011, 11:46 PM
 
sparrowdog sparrowdog is offline
 

eXpert
  
Join Date: Jan 2007
Posts: 244
 

Default Re: Inserting an initial value in to the search box

Thanks Darren. The javascript worked a charm.
__________________
Version 4.1.6 to 4.1.11
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:11 PM.

   

 
X-Cart forums © 2001-2020