I have an advanced search page with a drop down with some areas to search in.
Is there a way I can link to the search page and make the drop down preselect the option I want.
This is so that I can have a link to "search audio" that goes to the page and has the dropdown set to "audio"
Not without some JavaScript tomfoolery, I suspect. Nice feature request, though.
[quote]Not without some JavaScript tomfoolery, I suspect. Nice feature request, though.
[right][post=“14229”]<{POST_SNAPBACK}>[/post][/right][/quote]
Thanks, It’d be quite nice if the dropdown all displayed the section you just searched in, rather than the all (this is when printing intitial screen on results screen).
Another great feature request ? 
[quote]Another great feature request ? 
[right][post=“14237”]<{POST_SNAPBACK}>[/post][/right][/quote]
Indeed. 
[quote]Indeed. 
[right][post=“14238”]<{POST_SNAPBACK}>[/post][/right][/quote]
I think I’ll go down the javascript path for the moment. If I come up with anything interesting I’ll post it here…
Bug tracker is here: http://bugs.matrix.squiz.ne
Forum posts usually do not automagically turn into feature requests
[quote]Bug tracker is here: http://bugs.matrix.squiz.ne
Forum posts usually do not automagically turn into feature requests
[right][post=“14249”]<{POST_SNAPBACK}>[/post][/right][/quote]
Oh, I’m sure Richard is quite aware of that. 
[quote]Oh, I’m sure Richard is quite aware of that. 
[right][post=“14250”]<{POST_SNAPBACK}>[/post][/right][/quote]
True. But perhaps someone there at Squiz is itching to code this, which I am not aware of. 
Because the search page submits data via the query string in the URL, you should be able to use something like this to preselect your option once the page has loaded.
(untested - concept only)
// Where ### is your category name
var categoryName = '###';
function getQueryVariable(sVariableName) {
var sQuery = window.location.search.substring(1);
var aVars = sQuery.split("&");
for ( var i=0;i< aVars.length;i++) {
var aPair = aVars[i].split("=");
if ( aPair[0] == sVariableName) {
return aPair[1];
}
}
}
window.onload = function() {
// Automatically change list selected index based on category name in query string
var sCategoryValue = getQueryVariable('category_' + categoryName );
var oSelectCategoryField = document.getElementById('selectCategory');
for ( var i = 1; i <= oSelectCategoryField.options.count -1; i ++ ) {
if ( oSelectCategoryField.options[i].value == sCategoryValue ) {
oSelectCategoryField.options[i].selected = true;
}
}
}
[quote]Because the search page submits data via the query string in the URL, you should be able to use something like this to preselect your option once the page has loaded.
(untested - concept only)
[right][post=“14282”]<{POST_SNAPBACK}>[/post][/right][/quote]
Many thanks for that - yes it does work when I replace the various params to suit our system. I also worked up a solution, but yours is more elegant.
An interesting observation - when running this code and including initial results page on the results page, the popup sets itself to the correct value as well.
Once I have a production version of it running I’ll post the code back to you - you might want to include it in the release.
cheers
Richard
Actually there is something odd in the onload function -I changed the index selection bit to the code I had in my function… odd.
Try out the Advanced search.
Search for Kim hill in “Audio”.
You can also go directly to Advanced search.
Excellent, nice to see it's all working for you 