SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Oct 2004
    Location
    Newport Beach
    Posts
    1,760
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript Place Text Input into URL, go to page

    I have a text input on a particular page with the option for the user to type in a four-digit year.

    Let's say 1981 for example.

    When the user clicks submit or enter, I don't want anything submitted, but rather javascript taking the user to url:

    http://www.mysite.com/year/1981

    How can I do this?

    Thanks
    Ryan
    Upcoming Movies - Movie News. Updated Daily.
    Movie Trailers - Awesome trailer site. Nuff said.

  2. #2
    SitePoint Addict
    Join Date
    Aug 2007
    Posts
    365
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have to place code in teh 'onSubmit" even of the form

    to prevent the form from submitting, you have to return false ( I could be wrong here, haven tried it recently) from the onSubmit event.

    <form ... onSubmit="javascript_to_do_here(); return false" >
    ..
    ..
    ..
    </form>


Bookmarks

Posting Permissions

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