Zen Cart Logo
Forums / General Questions / What could possibly disable the Search button?

What could possibly disable the Search button?

Locked

Views: 1,252

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
22 Apr 2009, 7:40 PM
#1
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

What could possibly disable the Search button?

I am trying to troubleshoot this myself, so I would appreciate hints or tips that will help me understand how this, all of a sudden, happened:

I have two test versions of my store: in both of them the search function works properly by entering keywords and hitting the Enter key on the keyboard.

However, in the earlier version, clicking the Search button also works. In the later store version, clicking the Search button doesn't work for some reason.

I compared the the CSS style for both - they are identical:

html > body #indexHomeBody > div #mainWrapper > div #headerWrapper > div #navMainWrapper > div #quick_find_header-Go > a .greenBold

I also compared the actual HTML code on each web site:

<div id="navMainSearch">
<form name="quick_find_header" action="http://www.mystore.com/test1/index.php?main_page=advanced_search_result" method="get"
<input type="hidden" name="main_page" value="advanced_search_result" />
<input type="hidden" name="search_in_description" value="1" />
<input type="text" name="keyword" maxlength="30" value="Enter keywords here" onfocus="if (this.value == 'Enter keywords here') this.value = '';" onblur="if (this.value == '') this.value = 'Enter keywords here';" /> 
</form>></div>

They are identical - except for the test1 vs. test2 internal URL, of course.

So, my question is: Where do I start looking?

22 Apr 2009, 7:52 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: What could possibly disable the Search button?

Have you tried running the page HTML through validation?
You probably have another <form> tag before your search form, that's not been closed properly.

22 Apr 2009, 8:25 PM
#3
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: What could possibly disable the Search button?

DrByte:

Have you tried running the page HTML through validation?
No, I didn't. What would be a suitable tool to do that? Do you have a preference as far as Zen-Cart is concerned?

Simply by Googling I found the following two:

http://validator.w3.org/

http://htmlhelp.com/tools/validator/

Are they all the same?

DrByte:

You probably have another <form> tag before your search form, that's not been closed properly.
With the validation tip and the <form> one I certainly have lead now. Thanks you!

22 Apr 2009, 8:27 PM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: What could possibly disable the Search button?

The w3 validator is probably the most popular.

If you've installed the Firefox "Webdeveloper Toolbar" extension, the validator links it uses point to the w3 service.

22 Apr 2009, 8:34 PM
#5
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: What could possibly disable the Search button?

DrByte:

The w3 validator is probably the most popular.

If you've installed the Firefox "Webdeveloper Toolbar" extension
Yes, I installed it but so far I have used only a fraction of its features (I am not a web developer by trade).

I just tried both and I was stunned: The "good" URL produces 30 errors! The bad URL produces 50 errors. This is amazing and I wonder where I was sleeping all that time, ignoring such a basic function of using an HTML validator.

Thank you again. Once I solve the problem, I will report back for the benefit of others.

23 Apr 2009, 2:04 AM
#6
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: What could possibly disable the Search button?

Progress report (the problem has not been solved completely yet):

If you look at the HTML code I posted above:

<div id="navMainSearch">
<form name="quick_find_header" action="http://www.mystore.com/test1/index.php?main_page=advanced_search_result" method="get"
<input type="hidden" name="main_page" value="advanced_search_result" />
<input type="hidden" name="search_in_description" value="1" />
<input type="text" name="keyword" maxlength="30" value="Enter keywords here" onfocus="if (this.value == 'Enter keywords here') this.value = '';" onblur="if (this.value == '') this.value = 'Enter keywords here';" /> 
</form>></div>

You will notice an extra '>' after </form>.

At first, I could swear this was the culprit. I fixed this in my template's tpl_header.php:

<div id="navMainSearch"><?php require(DIR_WS_MODULES . 'sideboxes/search_header.php'); ?></div>

But I didn't notice much difference (it somehow worked after the 3rd or 4th click, though).

I then realized that the same typo (extra '>') exists in the test copy that works, too. Hmmm...

I will close all browsers now and try again (perhaps cleaning the cache would do something). This is becoming a real weird problem.

23 Apr 2009, 2:30 AM
#7
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: What could possibly disable the Search button?

OK - I reloaded everything cleanly and the problem didn't go away. Moreover, even 3rd or 4th or Nth mouse-click doesn't trigger the search. So it seems that I imagined what I wrote above about "sometimes works".

Still, that extra '>' is surely a bug and it's good that I removed it. I now have to explore further. I didn't imagine that HTML would be so tricky to troubleshoot.

26 Apr 2009, 3:04 PM
#8
zcnb avatar

zcnb

Zen Follower

Join Date:
Jun 2008
Posts:
338
Plugin Contributions:
0

Re: What could possibly disable the Search button?

Update: I found the source of the problem :clap:: That "Search Button" (in the new template) was not a button but rather an <a href> linked that relied on an unnamed javascript function to work.

Since I got rid of javascript in the new template, that functionality ceased working.

One good thing that came out of this is raising my awareness to HTML validation (thank you, DrByte).

Yes, the site works as intended but with its dynamic nature (of constant improvements) one never knows when an HTML validation error/warning "time bomb" will be triggered to a state where it would be difficult to troubleshoot.

The lesson: Run HTML validation after each and every slight change. It may sound time consuming but in actuality this will save a lot of time & agony later on in the (never ending) project.