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 6 of 6
  1. #1
    New Coder
    Join Date
    Jun 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need a little help

    Ok, this should be easy but for me it doesn't seem so... probably because i'm very close to the deadline and have a lot to do.

    This is what i'm trying to do;
    I have an html form with a textfield and a button - whenever the button is clicked or enter is pressed i would like it to goto a particular page and place the text field's value on the end as a hash.

    for instance;
    user enters "test" and presses enter or hits the button and the page goes to "google.com#test"'

    edit: to clarify I would like it to add the hash on the end of the href for the page it should goto
    Last edited by anarch; 07-01-2011 at 02:55 AM.

  • #2
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,087
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Lightbulb

    Code:
    <!DOCTYPE HTML>
    <html>
    <head>
    <title> Untitled </title>
    <script type="text/javascript">
    function GoTo() {
      document.location = "http://www.google.com#"+document.getElementById('hashContent').value;
    }
    </script>
    
    </head>
    <body>
    Go to www.google#<input type="text" id="hashContent" value="">
    <button onclick="GoTo()">Go</button>
    </body>
    </html>
    Of course you realize that if the user miss-types the hash, it won't go where you want.

  • #3
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    it's probably a good idea to encodeURIComponent() the user input.

  • #4
    New Coder
    Join Date
    Jun 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    it doesn't matter what they type because it's a search field. I have to use the url bar to transfer information across joomla mods from one page to another.
    That method didn't work at all even with URI encoding.

    without uri encoding all it does is add "searchTerm=" to the url bar - with uri encoding it does get the word up there but not beginning with a # nor does it go to the page

  • #5
    Senior Coder jmrker's Avatar
    Join Date
    Aug 2006
    Location
    FL
    Posts
    3,087
    Thanks
    38
    Thanked 498 Times in 492 Posts

    Question

    Quote Originally Posted by anarch View Post
    it doesn't matter what they type because it's a search field. I have to use the url bar to transfer information across joomla mods from one page to another.
    That method didn't work at all even with URI encoding.

    without uri encoding all it does is add "searchTerm=" to the url bar - with uri encoding it does get the word up there but not beginning with a # nor does it go to the page
    So, bottom line is that neither suggestion helped?

  • #6
    New Coder
    Join Date
    Jun 2011
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Unfortunately not. -_-

    I already tried yours before coming here lol. I'm not sure why this is so complicated really... lol.


  •  

    Posting Permissions

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