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

Pre filled search text box

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-05-2008, 03:32 AM
  Warwick's Avatar 
Warwick Warwick is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Somewhere on the web through European connection
Posts: 868
 

Question Pre filled search text box

Is there somebody how knows how to pre fill the search text box with something lik 'Start searching ...'

And the so that when a visitor clicks in this text i.e. the search text box, it'll dissapear i.e. becomes empty?

At this moment I have {$searchstring|escape:'html'} in it because I use the Smart Search mod.

Any help is appreciated.
__________________
Installs: X-Cart 4.1.x - 4.4.x ∙∙ MySQL version: 5.0.45 ∙∙ Apache version: 2.2.8 (Unix) ∙∙ PHP version: 5.25
X-Cart add-ons: all ∙∙ Mods: A lot; too many ∙∙ Skin templates: Many
∙∙ Experience: Somewhere beyond newbie
-----------------------------------
------------------------------------------------------------------------------------------------------
Looking for the best dutch language pack? 4.1.x - 4.6.x compatibel, native speaker translation! More info
Reply With Quote
  #2  
Old 03-05-2008, 03:57 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Pre filled search text box

Add this to the search input box:

value="search for products..."onFocus="this.value=''"
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 03-05-2008, 03:59 AM
  Warwick's Avatar 
Warwick Warwick is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Somewhere on the web through European connection
Posts: 868
 

Default Re: Pre filled search text box

thanks balinor but should I then replace the '{$searchstring|escape:'html'}' whta is in it now?
__________________
Installs: X-Cart 4.1.x - 4.4.x ∙∙ MySQL version: 5.0.45 ∙∙ Apache version: 2.2.8 (Unix) ∙∙ PHP version: 5.25
X-Cart add-ons: all ∙∙ Mods: A lot; too many ∙∙ Skin templates: Many
∙∙ Experience: Somewhere beyond newbie
-----------------------------------
------------------------------------------------------------------------------------------------------
Looking for the best dutch language pack? 4.1.x - 4.6.x compatibel, native speaker translation! More info
Reply With Quote
  #4  
Old 03-05-2008, 04:05 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Pre filled search text box

If that is set for the value, yes, you can remove that.
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #5  
Old 03-05-2008, 04:34 AM
  Warwick's Avatar 
Warwick Warwick is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Somewhere on the web through European connection
Posts: 868
 

Default Re: Pre filled search text box

That works, love ya

You have any idea if this'll work with language variables?

I tried replacing value="search for products..."onFocus="this.value=''"

with $lng.lbl_my_text but that doesn't work
__________________
Installs: X-Cart 4.1.x - 4.4.x ∙∙ MySQL version: 5.0.45 ∙∙ Apache version: 2.2.8 (Unix) ∙∙ PHP version: 5.25
X-Cart add-ons: all ∙∙ Mods: A lot; too many ∙∙ Skin templates: Many
∙∙ Experience: Somewhere beyond newbie
-----------------------------------
------------------------------------------------------------------------------------------------------
Looking for the best dutch language pack? 4.1.x - 4.6.x compatibel, native speaker translation! More info
Reply With Quote
  #6  
Old 03-05-2008, 04:41 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default Re: Pre filled search text box

Use:

value="{$lng.lbl_my_text}" onFocus="this.value=''"
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #7  
Old 03-05-2008, 05:03 AM
  kube's Avatar 
kube kube is offline
 

X-Adept
  
Join Date: Sep 2005
Location: London: a small place East of Wales
Posts: 529
 

Default Re: Pre filled search text box

You could put the original value back too if the field was left empty... (similar to apple.com's prettysearch)...

value="{$lng.lbl_my_text}" onFocus="this.value='';" onBlur="if(this.value=='') this.value='{$lng.lbl_my_text}';"

The code might be a little bit much, but you never know
__________________
Doms
kube v4.1.9
Reply With Quote
  #8  
Old 03-05-2008, 10:15 PM
  Warwick's Avatar 
Warwick Warwick is offline
 

X-Adept
  
Join Date: Mar 2003
Location: Somewhere on the web through European connection
Posts: 868
 

Default Re: Pre filled search text box

You guys are the best! Works like a charme

But kube, what do you mean with the pretty search example, I noticed Apple's search box, but when you leave it empty, no search is performed. Can you explain what you're after with this code (which I've implemented like you said)?
__________________
Installs: X-Cart 4.1.x - 4.4.x ∙∙ MySQL version: 5.0.45 ∙∙ Apache version: 2.2.8 (Unix) ∙∙ PHP version: 5.25
X-Cart add-ons: all ∙∙ Mods: A lot; too many ∙∙ Skin templates: Many
∙∙ Experience: Somewhere beyond newbie
-----------------------------------
------------------------------------------------------------------------------------------------------
Looking for the best dutch language pack? 4.1.x - 4.6.x compatibel, native speaker translation! More info
Reply With Quote
  #9  
Old 03-06-2008, 03:04 AM
  kube's Avatar 
kube kube is offline
 

X-Adept
  
Join Date: Sep 2005
Location: London: a small place East of Wales
Posts: 529
 

Default Re: Pre filled search text box

My bad. What happens with apple's search field is obviously a little sophisticated. But for usability, if the field remains empty and you click elsewhere on the page instead of searching, the field returns to a default value (ie. it will return to saying 'Search' if left empty).

onFocus means the item is active
(in this case it will remove value of box) onFocus="this.value='';"

onBlur means the item is not active
(will return a value back into box if it is left empty) onBlur="if(this.value=='') this.value='{$lng.lbl_my_text}';"
__________________
Doms
kube v4.1.9
Reply With Quote
  #10  
Old 03-06-2008, 04:33 AM
 
carpeperdiem carpeperdiem is offline
 

X-Guru
  
Join Date: Jul 2006
Location: New York City, USA
Posts: 5,399
 

Default Re: Pre filled search text box

I agree with kube - apple.com search is very user friendly. A good model to emulate. The search box says, "search" until you click in it (then it is empty, waiting for input). As soon as the search results refresh, the search box again says, "search". As in kube's post #7
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4
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 03:53 PM.

   

 
X-Cart forums © 2001-2020