JS LINK: URL + VARIABLE - please help

Discussion in 'JavaScript' started by flym4zt3r, Jan 27, 2008.

  1. #1
    Hi. Sorry if this has already been answered but I can't find it and the search function doesn't work with the word 'url'.

    I've been searching for quite a while now, and can't figure this out, though I believe the answe is fairly simple.

    What I need to do is this:

    Text form in an html page. Visitor writes something there and when he clicks the go/submit button, the page goes to a predefined url + the given variable. Something like:

    ...

    var myvar = anything;

    ...

    textbox input = anything

    when submit button clicked:

    some_function( 'http://www.site.com' + myvar );

    something like: http://www.site.com/userdata


    Thank you and sorry for my bad english.
     
    flym4zt3r, Jan 27, 2008 IP
  2. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <form action="http://www.site.com/" onsubmit="location = this.action + this.myvar"><input type="text" name="myvar" /></form>
    HTML:
     
    MMJ, Jan 27, 2008 IP
  3. flym4zt3r

    flym4zt3r Peon

    Messages:
    103
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Kewl. Thanks a lot. This has solved one of my problems. Thank you, thank you, thank you, thank you. :D

    This wasn't really what I needed but it solved one of my probs. :) This solution gives the following result:

    mysite.com/?myvar=text-entered-by-user

    I edited the name and one it's done.
    But I still need to know if javascript can do this:

    mysite.com/text-entered-by-user - without any other specs.

    Anyway, thankx a lot, MMJ.
     
    flym4zt3r, Jan 27, 2008 IP
  4. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Oops!

    <form action="http://www.site.com/" onsubmit="location = this.action + this.myvar.value; return false"><input type="text" name="myvar" /></form>
    HTML:
     
    MMJ, Jan 27, 2008 IP
  5. flym4zt3r

    flym4zt3r Peon

    Messages:
    103
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks a lot! That's it! :D Thank you. :)
     
    flym4zt3r, Jan 27, 2008 IP