You are here:  » document.search.q is null or not an object

Support Forum



document.search.q is null or not an object

Submitted by clickspace on Wed, 2008-02-20 10:48 in

Hi there,

On my index page I have the following error but only in IE:

"document.search.q is null or not an object"

On the index page I have a standard text intro include, the featured products followed by the search form.

The only reference to search.q I can find is on index.php

print javascript_focus("search.q");

Any ideas?

Thanks,
Steven

Submitted by support on Wed, 2008-02-20 11:45

Hello Steven,

Thanks for pointing that out - it means that the "q" field in the search form is missing the id tag that will make the forum focus JavaScript work. In html/searchform.php look for the following line:

<input type='text' name='q' size='35' value='<?php print (isset($q)?$q:""); ?>' />

...and change this to:

<input type='text' name='q' id='q' size='35' value='<?php print (isset($q)?$q:""); ?>' />

(just add the id='q' tag)

That should remove the JavaScript error.

Cheers,
David.

Submitted by clickspace on Wed, 2008-02-20 13:29

Thanks David but it looks like the code in your reply is missing?

In any case, I think I was able to follow where I should add the id=q tag but that doesn't seem to have sorted it.

Here is my updated form code:

<form name='search' action='<?php print $config_baseHREF ?>search.php'>
    <input type='text' id='q' name='q' size='35' value='<?php print (isset($q)?$q:""); ?>' />&nbsp;
  <input name='search' type='image' class='alt' value='<?php print translate("Search"); ?>' src='http://www.domain.com/shop/images/search.png' align="middle" />
  </form>

Produces same error on the index page.

When using the same searchform.php include on other pages such as product and search results page there is no such error, although that's probably because they doesn't use javascript_focus("search.q")

Submitted by support on Wed, 2008-02-20 13:40

Hi,

Sorry about that - i've fixed up the code (missed out the code tags!).

Is there anything else on your index page that uses the name "search" at all, as the standard JavaScript created by the call to javascript_focus("search.q") is "document.search.q.focus()", which should work fine in IE.

Could you perhaps email me a link to your site so that I can take a look...(reply to your reg code or forum registration email)

Cheers,
David.