Go Back   CodingForums.com > :: Client side development > JavaScript programming > DOM and JSON scripting

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-25-2010, 01:12 AM   PM User | #1
boomer101
New to the CF scene

 
Join Date: Nov 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
boomer101 is an unknown quantity at this point
Post Search page and jump to text

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!

Last edited by boomer101; 11-25-2010 at 01:24 AM..
boomer101 is offline   Reply With Quote
Old 11-25-2010, 01:18 PM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
And $() would be? If you are a first time coder, do yourself a favor and start with learning JavaScript native language, and only afterward the dialect of a framework or another.
Quote:
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.
What's the use? Why to reinvent the wheel? All the modern browsers have already incorporated a Find-in-page widget. Just press CTRL+F and you'll see it.
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Last edited by Kor; 11-25-2010 at 01:23 PM..
Kor is offline   Reply With Quote
Old 11-25-2010, 05:38 PM   PM User | #3
boomer101
New to the CF scene

 
Join Date: Nov 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
boomer101 is an unknown quantity at this point
Quote:
Originally Posted by Kor View Post
All the modern browsers have already incorporated a Find-in-page widget. Just press CTRL+F and you'll see it.
It's actually a web app for iOS being written in HTML. Obviously mobile Safari doesn't have a find function.
boomer101 is offline   Reply With Quote
Old 11-25-2010, 05:49 PM   PM User | #4
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Aha. OK. I promise to think about
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Reply

Bookmarks

Tags
html, input, javascript, search

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:44 AM.


Advertisement
Log in to turn off these ads.