I just spent a few minutes tweaking the way the default Cartweaver categories search form works - it is fairly basic form javascript, but I think it might be useful to others...

This site is in progress - client has added (and named, sometimes a bit off-spelling) his products, and the CW functions are all up and working.

Rather than the standard secondary category functions, with this site we wanted a 'keyword' search function, much like the tags commonly assigned to blog posts. Most of his photos have multiple secondary categories assigned, so a picture of a river by a mountain for example, would show up under both rivers and mountains. you get the idea.

Cartweaver's search function allows for all sorts of configurations in the call for the search (see the default index.cfm page when you install CW... here is a sample - this is all the default search types plus a few custom ones I keep around... in this case we're working from the one labeled "All form defaults used"). I have the call to the search tag in place in my 'results' page, and have opted to turn off the text box search and the main category search, simply leaving the 'secondary' category search and a submit button with a value of "Go".

anyway... rather than requiring the viewer to select the option and click the submit button to run the search, I thought it would be slick if the select box auto-submitted the form when changed. So... in the cw tag that handles the search function, I simply added this to the <select> dropdown code


so the whole line for the select now looks like this:
 <select name="secondary" id="<cfoutput>#attributes.formid#</cfoutput>-secondary" onchange="document.<cfoutput>#attributes.formid#</cfoutput>.submit()">

(Note, I could have hand-coded the attributes.formID part since I am only using this once in the page, but this method is copying the ID given to the form by cartweaver through the FormID variable)

However... this alone does not work... because...
the default name for the submit button is - can you guess? - "submit", and , left to itself, my javascript code above makes the browser think its trying to do something with that button, rather than submit the form. So the easy fix - rename the submit button to "btnSubmit".

<input name="btnSubmit" type="submit" class="formButton" value="<cfoutput>#attributes.buttonlabel#</cfoutput>"> 

I could also have just removed (commented out) the submit button, since the dropdown now submits the form when changed, but if javascript is disabled, you need the button, so renaming it is the easy fix.

That's a long post for a short mod... hope it helps somebody some time.