| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Pre filled search text box | ||||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
![]() 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 ![]() ----------------------------------------------------------------------------------------------------------------------------------------- ![]() ![]() |
|||||||||
#2
|
|||||||
|
|||||||
![]() Add this to the search input box:
value="search for products..."onFocus="this.value=''"
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#3
|
|||||||||
|
|||||||||
![]() 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 ![]() ----------------------------------------------------------------------------------------------------------------------------------------- ![]() ![]() |
|||||||||
#4
|
|||||||
|
|||||||
![]() If that is set for the value, yes, you can remove that.
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#5
|
|||||||||
|
|||||||||
![]() 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 ![]() ----------------------------------------------------------------------------------------------------------------------------------------- ![]() ![]() |
|||||||||
#6
|
|||||||
|
|||||||
![]() Use:
value="{$lng.lbl_my_text}" onFocus="this.value=''"
__________________
Padraic Ryan Ryan Design Studio Professional E-Commerce Development |
|||||||
#7
|
|||||||||
|
|||||||||
![]() 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 |
|||||||||
#8
|
|||||||||
|
|||||||||
![]() 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 ![]() ----------------------------------------------------------------------------------------------------------------------------------------- ![]() ![]() |
|||||||||
#9
|
|||||||||
|
|||||||||
![]() 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 |
|||||||||
#10
|
|||||||
|
|||||||
![]() 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 |
|||||||
|
|||
X-Cart forums © 2001-2020
|