First time JS coder, I've written a very, VERY feeble attempt at this.
I have a page with about 2,000 listings. I want to build a search box that gets the inputed text, forwards it to some kind of JS function that will scroll the page to that entry on the page.
Here is the input box that I have so far:
Code:
<FORM NAME="myform" ACTION="" METHOD="GET">
<INPUT TYPE="text" size="30" NAME="inputbox" VALUE="" onClick="testResults(this.form)">
</FORM>
and the bad bad JS that it links to:
Code:
function testResults (form) {
var TestVar = form.inputbox.value;
var container = $('span'),
scrollTo = $(TestVar);
container.scrollTop(
scrollTo.offset().top - container.offset().top
);
}
Thanks soso much in advance!