Until the HTML5 input#search element becomes completely widespread,
you still may want to differentiate your search fields from the rest
of your form. Here’s a quick way to do this (using Prototype,
naturally).
var testSearch = new Element('input',{type:'search'});
var filter = $('filter');
if(testSearch.type == 'search'){
filter.writeAttribute('type','search');
}else{
filter.addClassName('search');
filter.up('div').insert('<div id="clear_filter">⨂</div>');
}
Then you need to have wrapped the filter field in a DIV with
position:relative or position:absolute on it, and you need the
following CSS to give the desired shape and positioning.
Just revisiting this as when I tried it before Christmas it wouldn’t work for me - and then I forgot about it!
I have tried it again but couldn’t get it to work unless I used Item Extended on the search field and added the parameters type:search to the Input Tab
My reading of the code is that this part should be done for you automatically - or have I got it wrong?
Can you clarify please - I currently have the code in Top Function Body of Protaculous using prototype and the CSS in before end head.
Change the name of the field you’re selecting to match your actual
search form input:
var filter = $('q');
Walter
On Feb 5, 2011, at 10:27 AM, DeltaDave wrote:
Hi Walter
Just revisiting this as when I tried it before Christmas it wouldn’t
work for me - and then I forgot about it!
I have tried it again but couldn’t get it to work unless I used Item
Extended on the search field and added the parameters type:search to
the Input Tab
My reading of the code is that this part should be done for you
automatically - or have I got it wrong?
Can you clarify please - I currently have the code in Top Function
Body of Protaculous using prototype and the CSS in before end head.
Sadly, it’s a Freeway thing. If it’s an input you’re adding yourself, you need to use Item / Extended to put it back where it belongs. I’ve also written an Action to sort this, look for FormFix in the Forge; but I haven’t tested it with the Site Search Action, so I don’t know if it leaps in at the appropriate moment in order to alter that field or not.
Just to wrap this up in a bow, here’s the instructions and code all in one place.
Click once on your search field, move to the third tab from the left in the Inspector, and check what the name attribute is set to. Use Item / Extended to add a matching id attribute to the input itself, not the enclosing DIV if any.
Use Protaculous to add the following JavaScript code, and use Page / Extended or the External Stylesheets Action to add the following CSS.