Results 1 to 10 of 10

Thread: Append form input to a URL

  1. #1
    Join Date
    May 2008
    Location
    NE Florida
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Append form input to a URL

    I need a script that will take the input from a form text box and insert it to a URL then take the viewer there.

    A fixed portion of the url would be:

    http://www.domain.com/-p-#.html

    The form needs to replace the "#" with a number entered into the text box to produce a url like:

    http://www.domain.com/-p-1234.html

    Then the SUBMIT button would take the viewer to that URL.

    Can be javascript or php. either is just fine with me.

    Does anyone know of such a script?

    Last edited by stuffdone; 05-27-2008 at 06:31 PM. Reason: Note:

  2. #2
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    Code:
    <form action="INITIAL_URL" method="get">
    <input type="text" name="VARIABLE" value="VALUE">
    <input type="submit" value="submit"
    </form>
    will produce

    INITIAL_URL&VARIABLE=VALUE

  3. #3
    Join Date
    May 2008
    Location
    NE Florida
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks. I will experiment with it !

  4. #4
    Join Date
    May 2008
    Location
    NE Florida
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    <form action="INITIAL_URL" method="get">
    <input type="text" name="VARIABLE" value="VALUE">
    <input type="submit" value="submit"
    </form>

    INITIAL_URL&VARIABLE=VALUE

    ==
    Initial would be:

    http://www.domain.com/-p- VALUE

    I need .html added after VALUE ? How do I do that?

    http://www.domain.com/-p- VALUE.html

    Sorry not a programmer !

  5. #5
    Join Date
    May 2008
    Location
    NE Florida
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Problems

    Quote Originally Posted by stuffdone View Post
    <form action="INITIAL_URL" method="get">
    <input type="text" name="VARIABLE" value="VALUE">
    <input type="submit" value="submit"
    </form>

    INITIAL_URL&VARIABLE=VALUE
    The first issue is this inserts a "?" in the URL which breaks it.

    Resulting URL has to be clean or won't function.

    results exactly like:

    http://www.domain.com/-p-VARIABLE.html

    Thanks.

  6. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    after reviewing the initial post and this last 2, you are actually going to need to use some javascript, however it will not be accessible to everyone, because every user can disable javascript if they so choose. if you had access to a server-side language like php this could be done, however i am going to assume that you dont, so below is the client-side method

    Code:
    <script type="javascript">
    function goToPage(var url = '')
    {
        var initial = "http://www.domain.com";
        var extension = "html";
    
        window.location(initial+url+extension);
    }
    </script>
    
    <form name="something" action="#">
    Label <input type="text" name="url" value="" onchange="goToPage(this.value)">
    </form>

  7. #7
    Join Date
    May 2008
    Location
    NE Florida
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by boogyman View Post
    after reviewing the initial post and this last 2, you are actually going to need to use some javascript, however it will not be accessible to everyone, because every user can disable javascript if they so choose. if you had access to a server-side language like php this could be done, however i am going to assume that you dont, so below is the client-side method

    Code:
    <script type="javascript">
    function goToPage(var url = '')
    {
        var initial = "http://www.domain.com";
        var extension = "html";
    
        window.location(initial+url+extension);
    }
    </script>
    
    <form name="something" action="#">
    Label <input type="text" name="url" value="" onchange="goToPage(this.value)">
    </form>
    Here is the actual sample. The above did not seem to work for me. I am really the only one it has to work for because the initial page will be loaded locally only, probably not posted on the server at all.

    http://www.blossompromotions.com/-p-5004.html ( actual url )

    http://www.blossompromotions.com/-p-VARIABLE.html

    The script needs to insert the VARIABLE then redirect to the complete URL shown or such other as would result with various numbers entered.

    Thanks guy...appreciate your help.

  8. #8
    Join Date
    May 2008
    Location
    NE Florida
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    This is what appears in the address bar:

    file:///J:/1-WORK/1_Web_Sites/Pool/blossom1.html?url=5005#

    What should appear is:

    http://www.blossompromotions.com/-p-5005.html

    Should not be dependent on the physical location of the script as it will be used locally from desktop, not from the server.

  9. #9
    Join Date
    May 2008
    Location
    NE Florida
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I placed a <BASE REF in the header. It does not go to the correct domain, however the URL contains a "?" as:

    http://www.blossompromotions.com/?url=5005#

    It needs to be

    http://www.blossompromotions.com/-p-5005.html

    I will try again with the base including the /-p- and see what happens

  10. #10
    Join Date
    May 2008
    Location
    NE Florida
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default My HTML

    <HTML>
    <HEAD>
    <SCRIPT type="javascript">
    function goToPage(var url = '')
    {
    var initial = "http://www.blossompromotions.com/-p-";
    var extension = "html";

    window.location(initial+url+extension);
    }
    </SCRIPT>
    <TITLE>Redirect 1</TITLE>
    <BASE HREF="http://www.blossompromotions.com/">
    </HEAD>
    <BODY>
    <P>
    <FORM name="something" action="#">
    Label
    <INPUT type="text" name="url" value="" onSubmit="goToPage(this.value)">
    <INPUT type="submit" value="GO">
    </FORM>
    </BODY></HTML>

    =====

    It will load the correct domain but the URL is still not correct. It results in this. ( example input 5005 )

    http://www.blossompromotions.com/?url=5005#

    Should be:

    http://www.blossompromotions.com/-p-5005.html

    ===/ note /===

    This seems to work same:

    <SCRIPT type="javascript">
    function goToPage(var url = '')
    {
    window.location(http://www.blossompromotions.com/-p-+url+.html);
    }
    </SCRIPT>

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
  •