|
Answer» Hi folks,
On my search form I have the following script in the head: Code: [Select]<script language="JavaScript1.3" TYPE="text/javascript" src="jse_form.js">And in the body is the following: Code: [Select]<form name="jse_Form" onsubmit="search_form(jse_Form);return false"> <input type="text" name="d"> <input type="button" value="Go" onclick="search_form(jse_Form)"> </form> On the results page is the following script in the head: Code: [Select]<script language="JavaScript1.3" type="text/javascript" src="jse_form.js"></script> <script language="JavaScript1.3" type="text/javascript" src="jse_search.js"></script>And in the body: Code: [Select]<!-- Find -->
<form name="jse_Form" onsubmit="search_form(jse_Form);return false"> <input type="text" name="d"> <input type="button" value="Go" onClick="search_form(jse_Form)"> </form> <script language="JavaScript1.3" type="text/javascript">return_query()</script>
<!-- Mid -->
<script language="JavaScript1.3" type="text/javascript">num_jse()</script> page(s) found <hr> <p> <script language="JavaScript1.3" type="text/javascript"> out_jse() </script> Which line could possibly be the cause of the script not being able to find any results from all pages of my website?
Thanks for any help, BurtonFor a start please show us 'jse_form.js' and 'jse_search.js' so we can review them. Also, when you have an onclick attribute for a button, you don't need to have an onsubmit attribute in the form. Try this: (the same for the search page and the results page)
Code: [Select]<form name="jse_Form"> <input type="text" name="d"> <input type="button" value="Go" onclick="search_form(jse_Form);return false"> </form> This is the "jse_search.js" file:
Code: [Select] // ---------- script properties ----------
var include_num = 1; var BOLD = 0;
// ---------- sites ----------
var s = new Array();
s[0] = "JSE^form.html^Enter JSE in the example above ...^open source, free, client side"; s[1] = "JSE DOCUMENTATION^doc.txt^JSE is a client-side local site search engine. WRITTEN entirely in JavaScript 1.3 it works with browsers from Netscape 4.7 to MICROSOFT Internet Explorer 6.0 ...^ faq, docs, instructions";
// ---------- end of script properties and sites ----------
var cookies = document.cookie; var p = cookies.indexOf("d=");
if (p != -1) { var st = p + 2; var en = cookies.indexOf(";", st); if (en == -1) { en = cookies.length; } var d = cookies.substring(st, en); d = unescape(d); } var OD = d; var m = 0; if (d.charAt(0) == '"' && d.charAt(d.length - 1) == '"') { m = 1; }
var r = new Array(); var co = 0;
if (m == 0) { var woin = new Array(); var w = d.split(" "); for (var a = 0; a < w.length; a++) { woin[a] = 0; if (w[a].charAt(0) == '-') { woin[a] = 1; } } for (var a = 0; a < w.length; a++) { w[a] = w[a].replace(/^\-|^\+/gi, ""); } a = 0; for (var c = 0; c < s.length; c++) { pa = 0; nh = 0; for (var i = 0; i < woin.length; i++) { if (woin[i] == 0) { nh++; var pat = new RegExp(w[i], "i"); var rn = s[c].search(pat); if (rn >= 0) { pa++; } else { pa = 0; } } if (woin[i] == 1) { var pat = new RegExp(w[i], "i"); var rn = s[c].search(pat); if (rn >= 0) { pa = 0; } } } if (pa == nh) { r[a] = s[c]; a++; } } co = a; }
if (m == 1) { d = d.replace(/"/gi, ""); var a = 0; var pat = new RegExp(d, "i"); for (var c = 0; c < s.length; c++) { var rn = s[c].search(pat); if (rn >= 0) { r[a] = s[c]; a++; } } co = a;
}
function return_query() { document.jse_Form.d.value = od; }
function num_jse() { document.write(co); }
function out_jse() { if (co == 0) { document.write('Your search did not match any documents.<p>Make sure all keywords are spelt correctly.<br>Try different or more general keywords.'); return; } for (var a = 0; a < r.length; a++) { var os = r[a].split("^"); if (bold == 1 && m == 1) { var br = "<b>" + d + "</b>"; os[2] = os[2].replace(pat, br); } if (include_num == 1) { document.write(a + 1, '. <a href="', os[1], '">', os[0], '</a><br>', os[2], '<p>'); } else { document.write('<a href="', os[1], '">', os[0], '</a><br>', os[2], '<p>'); } }
}
And this the "jse_form.js" code: Code: [Select]// ---------- script properties ----------
var results_location = "results.html";
// ---------- end of script properties ----------
function search_form(jse_Form) { if (jse_Form.d.value.length > 0) { document.cookie = "d=" + escape(jse_Form.d.value); window.location = results_location; } } Which section shows which parts of the website are being searched through? Maybe that is where the problem lies, as it isnt searching the site properly (just the page)?Quote from: burton on February 28, 2008, 04:53:48 AM Which section shows which parts of the website are being searched through? Maybe that is where the problem lies, as it isnt searching the site properly (just the page)?
Could somebody else help please if kpac doesnt know Kpac doesnt seem to be around any more.... could somebody else please help
|