Jquery & searchbox

Modules, Add-ons and custom code that's more than just a quick hack or Mod.
Post Reply
Painstik
Posts: 122
Joined: Sun Jul 19, 2009 1:19 pm
Location: Croatia

Jquery & searchbox

Post by Painstik »

Make an search box like here on this forum.

When you click on input text box "Search..." dissapears, when you click out it appears again.

Open: Panels/Header.Search.html
Find:

Code: Select all

<input type="text" name="search_query"
Change:

Code: Select all

value="%%LNG_Search%%..."
Add at the end of document, after </script>:

Code: Select all

<script type="text/javascript">
            $(document).ready(function() {
               $("#search_query").click(function(e) {
                  $("#search_query").attr({ value: '' });
               });
               $("#search_query").blur(function(){
                  if($(this).attr("value") == "") $(this).attr("value", " %%LNG_Search%%...");
               });
               $(".Button").click(function(e) {
                  if($("#search_query").attr("value") == " %%LNG_Search%%...") $("#search_query").attr("value", "");
                  });
            });
         </script>
Now you can remove h2 label tag, because you have it now inside of search box.
Last edited by Painstik on Mon Oct 12, 2009 2:47 pm, edited 1 time in total.
Need custom coding for Interspire Shopping Cart? Contact me
CharlieFoxtrot
Confirmed
Confirmed
Posts: 413
Joined: Sun Aug 09, 2009 1:23 pm

Re: Jquery & searchbox

Post by CharlieFoxtrot »

Very nice!

What happens if customer clicks on the search BUTTON without entering any text? Will a search be performed on the "search..." text that's already displayed in the field?
ISC 4.0.7

"... and let's be honest that whole "by design" thing is getting old too."
Painstik
Posts: 122
Joined: Sun Jul 19, 2009 1:19 pm
Location: Croatia

Re: Jquery & searchbox

Post by Painstik »

Yes, it will search for "search...", I'll try to fix that now. Thanks.
Need custom coding for Interspire Shopping Cart? Contact me
Painstik
Posts: 122
Joined: Sun Jul 19, 2009 1:19 pm
Location: Croatia

Re: Jquery & searchbox

Post by Painstik »

Ok, this was easy.

Code: Select all

<script type="text/javascript">
				$(document).ready(function() {
					$("#search_query").click(function(e) {
						$("#search_query").attr({ value: '' });
					});
					$("#search_query").blur(function(){
						if($(this).attr("value") == "") $(this).attr("value", " %%LNG_Search%%...");
					});
					$(".Button").click(function(e) {
						if($("#search_query").attr("value") == " %%LNG_Search%%...") $("#search_query").attr("value", "");
						});
			   });
			</script>
Now it will popup that you didn't wrote anything...
Need custom coding for Interspire Shopping Cart? Contact me
CharlieFoxtrot
Confirmed
Confirmed
Posts: 413
Joined: Sun Aug 09, 2009 1:23 pm

Re: Jquery & searchbox

Post by CharlieFoxtrot »

Perfect! :D
ISC 4.0.7

"... and let's be honest that whole "by design" thing is getting old too."
Post Reply