Hi,
I wanted to move the search to the header so I copied the content to the header.
<label for='q'>Zoek: </label> <input class='inputfield' type='text' id='q' name='q' size='35' value='<?php print (isset($header["title"])?$header["title"]:""); ?>' />
<input class='inputfield' type='submit' value='ZOEK' />
But if I do a search in it, it returns no results, while the same search on the normal search location delivers results.
You can check it on:
{link saved}
searchterm: colin
I'm forgetting something?
Hi,
I just noticed something strange. I changes the name="s" to name="q" but if you go to the website you will notice the cursor is in the searchbox instead of the searchbox is displaying the text 'Doorzoek de website...'
I replaced the q back to the s and then the text is displayed. Strange, do you know what it can be?
Here is the bit of code in the header.php:
<input type="text" value="Doorzoek de website…" name="q" class="s" onfocus="if (this.value == 'Doorzoek de website…') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Doorzoek de website…';}" />
<input type="submit" class="searchsubmit" value="Zoek" />
Hi Marco,
I think I know what this is - the default index.php includes a piece of JavaScript that sets focus to the q text box, and I notice that your code is clearing the text on the onfocus() event. The first thing I would suggest - assuming you'd like to keep the auto-focus would be to change
onfocus
to
onchange
...and that should do the trick!
Cheers,
David.
--
PriceTapestry.com
Thanks,
I changed javascript_focus to javascript_onChange and that solved it.
The cursor is gone from the searchbox but it did also something to my sidebar. It disappeared from the 'frontpage'.
If I change it back to javascript_focus it is there again.
Any idea on this?
Hi Marco,
The JavaScript created by the home page is in the distribution at line 30 of index.php by the following code:
print javascript_focus("search.q");
...which creates the following in the output:
<script type='text/javascript'>document.search.q.focus();</script>
Now if this fails, it could stop JavaScript execution on your page, and if your sidebar relies on JavaScript then that could be why it doesn't appear.
For this to work, make sure that the search form in your header has name='search' in the <form> tag, e.g.
<form name='search' action='<?php print $config_baseHREF ?>search.php'>
...
</form>
(that's as it is in the distribution html/searchform.php)
Make sure specifically that your sidebar doesn't also contain a search form with the same name - if it does, and you want 2 search boxes make sure that the opening form tag has a different name=... attribute - that should be all it is...
Cheers,
David.
--
PriceTapestry.com
Hi,
The searchform.php is pretty empty. I put the searchcode in the header.php. There I allready have:
<form name='search' action='<?php print $config_baseHREF ?>search.php'>
<input type="text" value="Doorzoek de website…" name="q" class="s" onfocus="if (this.value == 'Doorzoek de website…') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Doorzoek de website…';}" />
<input type="submit" class="searchsubmit" value="Zoek" />
</form>
PS: The disappearing sidebar was something else. I was working on an old version of index.php
Hi Marco,
The form looks fine now - if it's still not working as you are expecting if you could let me know what's not working the URL where I can see the problem I'll take a look at the code of the whole page...
Cheers,
David.
--
PriceTapestry.com
it is in:
{link saved}
You'll see that the cursor is in the search box.
Thanks, Marco.
It's only being cleared because the JavaScript to set focus to the search box is still in place - perhaps the best thing to do would be to remove that - in your index.php for that site, look for the following line:
print javascript_focus("search.q");
...and either comment out or delete that line. Alternative, if you would still like to have the search box have focus on page load for the convenience of your visitors, try experimenting with onkeydown instead of onfocus in your search box code...
Hope this helps!
Cheers,
David.
--
PriceTapestry.com
Hi Marco,
The code currently in your header is making the search box with name='s' but it should be name='q'. The part you posted above currently appears to be commented out, so if you change name='s' to name='q' that should be all it is...
Cheers,
David.
--
PriceTapestry.com