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
    May 2012
    Posts
    3
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Simple javascript redirect button

    Hello. I have searched for a solution to this (google and this forum) but I havent found a satisfactory answer. I know that this is probably very simple, but I really would appreciate some help.

    To outline. I have a page on www.example.com
    On that page I need to have a textbox, and a submit button. When the button is clicked, I need the page to redirect to www.example.com/"textboxvalue".

    So if for example "Customer1" is entered into the textbox, I would like the button to load the page http://www.example.com/customer1

    I'd be really greatful if someone could point me in the right direction for this.
    Many thanks in advance

  • #2
    New to the CF scene
    Join Date
    May 2012
    Posts
    3
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by iBall View Post
    This sounds like a homework exercise, but the basic steps are:

    1. attach an onclick event handler to the button.

    2. when the button is clicked, the event handler gets the value from the textbox using getElementById() to access the textbox object in the DOM.

    3. Then get the user input from the value attribute of the textbox object and append it to the base url you have.

    4. Then use window.location.href to redirect to the url in 3.
    Hiya iBall thanks for the quick reply. I can assure you this isn't homework (I'm 26) this is for my partner's website. At the moment customers have to manually type the address of their details page.

    I thought that being able to enter their username in a login style box would add a touch of professionalism.

    Thanks again for the help though. I shall give it another go and see what I can do

  • #3
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    852
    Thanks
    173
    Thanked 94 Times in 94 Posts
    Hi

    This might get you going

    see post2

    http://www.codingforums.com/showthread.php?t=262140

    LT
    "The greatest revenge is to accomplish what others say you cannot do."
    ~ Unknown

    I used to be indecisive, but now I'm not so sure.

  • Users who have thanked low tech for this post:

    HurtleUK (05-24-2012)

  • #4
    New to the CF scene
    Join Date
    May 2012
    Posts
    3
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you both so much for your help. This is exactly what I'm looking for


  •  

    Posting Permissions

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