Automatically erasing search box text
Automatically erasing search box text
Someone asked me to make the search box automatically erase the prepopulated text when someone clicks into it. I couldn't figure out how to do it with the existing module tags, so I added the following hack to action.default.php
On line 28 of action.default.php I added:
$dis = "onfocus=\"if(this.value==this.defaultValue) this.value='';\"";
and to line 33 I added the variable $dis to the end:
$this->smarty->assign('inputbox', $this->CreateInputText($id, 'searchinput', $searchtext, 20, 50, $dis));
This probably isn't the best way to do it, but it worked for me, so I'm passing it along. If anyone has a better way, please let me know. Otherwise, if you need it, enjoy.
On line 28 of action.default.php I added:
$dis = "onfocus=\"if(this.value==this.defaultValue) this.value='';\"";
and to line 33 I added the variable $dis to the end:
$this->smarty->assign('inputbox', $this->CreateInputText($id, 'searchinput', $searchtext, 20, 50, $dis));
This probably isn't the best way to do it, but it worked for me, so I'm passing it along. If anyone has a better way, please let me know. Otherwise, if you need it, enjoy.
Re: Automatically erasing search box text
Like this one - will be my default for future
...

Re: Automatically erasing search box text
Maybe this could be rolled into the Search module as a default action?
I can't think of any situations where one wouldn't want the search text box to operate this way.
I can't think of any situations where one wouldn't want the search text box to operate this way.
Re: Automatically erasing search box text
nice one, thanks .... i was trying to figure out how to do this myself
Re: Automatically erasing search box text
Wonderful, thank you!
Re: Automatically erasing search box text
create new feature request in forge
Re: Automatically erasing search box text
I am new to CMSMadeSimple..
But where is this file action.default.php is located? Which folder, subfolder of CMSmadeSimple
But where is this file action.default.php is located? Which folder, subfolder of CMSmadeSimple
Re: Automatically erasing search box text
To extend it a little so it falls back to default if the user leave the searchbox without searching:moorezilla wrote: On line 28 of action.default.php I added:
$dis = "onfocus="if(this.value==this.defaultValue) this.value='';"";
$dis = "onfocus="if(this.value==this.defaultValue) this.value='';""." onBlur="if(this.value=='') this.value=this.defaultValue;"";
- Elijah Lofgren
- Power Poster
- Posts: 811
- Joined: Mon Apr 24, 2006 1:01 am
Re: Automatically erasing search box text
I think I'll try getting this into the core. 

Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. 

Re: Automatically erasing search box text
Nice.
If you use a variable, my Rhodesian Ridgeback insists that you use "hogan" in his honor.
If you use a variable, my Rhodesian Ridgeback insists that you use "hogan" in his honor.
- Elijah Lofgren
- Power Poster
- Posts: 811
- Joined: Mon Apr 24, 2006 1:01 am
Re: Automatically erasing search box text
Applied: http://viewsvn.cmsmadesimple.org/viewsv ... w=rev 

Thanks for the patch!!!
All future CMSMS versions should include this.
Thanks again,
Elijah

Donemoorezilla wrote: Nice.
If you use a variable, my Rhodesian Ridgeback insists that you use "hogan" in his honor.

Thanks for the patch!!!

All future CMSMS versions should include this.
Thanks again,
Elijah
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. 

Re: Automatically erasing search box text
Is this only for the search module.? Can it work on pisearch, there is no such file under the pisearch module folder. thanks
- Elijah Lofgren
- Power Poster
- Posts: 811
- Joined: Mon Apr 24, 2006 1:01 am
Re: Automatically erasing search box text
It's even easier on Pisearch.fiddle wrote: Is this only for the search module.? Can it work on pisearch, there is no such file under the pisearch module folder. thanks

1. Go to Content -> Pisearch
2. In the Form template
Replace this line:
Code: Select all
<input type="text" value="" maxlength="50" size="15" name="pisearch" id="searching" />
Code: Select all
<input type="text" value="Search Text..." maxlength="50" size="15" name="pisearch" id="searching" onfocus="if(this.value==this.defaultValue) this.value='';" />
Elijah
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. 
