Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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.
    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.
    Last edited by Kor; 11-25-2010 at 01:23 PM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Aha. OK. I promise to think about
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •