Does anyone have a way of doing the equivalent of a form GET, but using the
search/engine/friendly URLS, so the results page can be bookmarked?
ie the results page URL looks like:
index.cfm/fuseaction/search/text/findthis
I've written a bit of javascript which seems to do the trick - i'm no js
expert, and i just knocked it up while we lost our network connection.
Also, it works like a normal form submit if js is disabled (i think, though
i haven't tried it on NS...)
here it is anyway:
here's how i call it:
<input type="Submit"
name="bsearch"
value="Search"
onclick="return sefformget(this.form.name,'/index.cfm/bsearch/1');">
and heres the .js file stuff:
// start of .js file
var aNames = new Array();
function myobj(oname, ovalue){
this.oname = oname;
this.ovalue = ovalue;
}
function addtoarray(n,v){
if (v.length > 0){
for (var i = 0; i < aNames.length ; i++) {
if (aNames[i].oname == n) {
aNames[i].ovalue = aNames[i].ovalue + ',' + v;
return true;
}
}
aNames[aNames.length] = new myobj(n,v);
return false;
}
return false;
}
function sefformget(myform,str) {
var f = document.forms[myform];
var ln = f.elements.length;
for (var i = 0; i < ln; i++) {
var e = f.elements[i];
var t = e.type;
var n = e.name;
var v = e.value;
if ((t == 'checkbox' || t=='radio') && (e.checked == true)) {
addtoarray(n,v);
} else if (t == 'text' || t == 'hidden' || t == 'textarea') {
v = escape(v);
v = v.replace(/\//g,'%2F');
addtoarray(n,v);
} else if (t == 'select-one' || t == 'select-multiple') {
for (var j = 0; j < e.length; j++) {
if (e.options[j].selected == true) {
v = e.options[j].value;
addtoarray(n,v);
}
}
}
}
for (var i = 0; i < aNames.length ; i++) {
str = str + '/' + aNames[i].oname + '/' + aNames[i].ovalue;
}
window.location = str;
return false;
}
// end of .js file
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists