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 8 of 8

Thread: Url

  1. #1
    New Coder
    Join Date
    Jul 2010
    Posts
    66
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Url

    Hi Guys,

    I want to have a text field where someone can enter a URL to go to. How can I do this?

    Maybe a stupid questions lol!

    Thanks

    Joe

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    Despite the fact that everyone already has a text field into which they can enter a URL and go anywhere in the WWW built into their browser...

    Code:
    <form action="#" onsubmit="window.location='http://'+this.url.value;return false;">
    <input type="text" name="url">
    <input type="submit" value="Go">
    </form>

  • #3
    New Coder
    Join Date
    Jul 2010
    Posts
    66
    Thanks
    11
    Thanked 0 Times in 0 Posts
    I know it sounds odd lol XD Thanks for the info.... Basically what I am trying to do is have a place where a user can enter their membership number into a text field, hit submit and they will be forwarded to their profile.

    Is there any way that the first part of the URL can be hidden so they just have to put the username in the box....

    e.g :

    Hidden bit : http://www.yourdomain.co.uk/user/

    Then in the text field : 01010101


    Hope this makes sense...

    Thanks

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    Just like you said.

    Code:
    <form action="#" onsubmit="window.location='http://www.yourdomain.co.uk/user/'+this.user.value;return false;">
    <input type="text" name="user">
    <input type="submit" value="Go">
    </form>
    Put 01010101 in the box and hit go will take you to http://www.yourdomain.co.uk/user/01010101 - of course this can't check whether that is a valid URL.
    Last edited by kansel; 04-16-2011 at 02:37 AM. Reason: typo

  • Users who have thanked kansel for this post:

    joesruddock (04-16-2011)

  • #5
    New Coder
    Join Date
    Jul 2010
    Posts
    66
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Thanks for the help Much appreciated

  • #6
    New Coder
    Join Date
    Jul 2010
    Posts
    66
    Thanks
    11
    Thanked 0 Times in 0 Posts
    Code:
    <form action="#" onsubmit="window.location='http://www.yourdomain.co.uk/user/'+this.user.value;return false;">
    <input type="text" name="user">
    <input type="submit" value="Go">
    </form>
    How would I add a file format after the user e.g.

    http://www.yourdomain.co.uk/user/userinput.fileformat ?

  • #7
    The Apostate Apostropartheid's Avatar
    Join Date
    Oct 2007
    Posts
    3,215
    Thanks
    16
    Thanked 265 Times in 263 Posts
    Quote Originally Posted by joesruddock View Post
    Code:
    <form action="#" onsubmit="window.location='http://www.yourdomain.co.uk/user/'+this.user.value;return false;">
    <input type="text" name="user">
    <input type="submit" value="Go">
    </form>
    How would I add a file format after the user e.g.

    http://www.yourdomain.co.uk/user/userinput.fileformat ?
    Have you attempted to do this yourself?

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    If the file format is a known static value (like .html) then after the this.user.value part put a plus sign and then the extension with single quotes around it.
    Code:
    <form action="#" onsubmit="window.location='http://www.yourdomain.co.uk/user/'+this.user.value+'.fileformat';return false;">
    <input type="text" name="user">
    <input type="submit" value="Go">
    </form>
    *You might need to scroll the code text box to see the changes highlighted in blue.


  •  

    Posting Permissions

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