Dynamic creation of URL

Discussion in 'Javascript' started by paul544, Oct 11, 2003.

  1. paul544

    paul544 Guest

    I need a script that will allow a user to enter variables into a form
    and then have a script generate a URL based on the input and then go
    there.

    I have an intranet. The address format is the same, but there are 2
    variables in the address that change. Normally the entire address
    must be typed in order to change what you want. I'd like to make it
    easier by just parsing input from two fields and put them in an
    address.

    Any help is appreciated.
    paul544, Oct 11, 2003
    #1
    1. Advertising

  2. Hi,

    paul544 wrote:
    > I need a script that will allow a user to enter variables into a form
    > and then have a script generate a URL based on the input and then go
    > there.
    >
    > I have an intranet. The address format is the same, but there are 2
    > variables in the address that change. Normally the entire address
    > must be typed in order to change what you want. I'd like to make it
    > easier by just parsing input from two fields and put them in an
    > address.
    >
    > Any help is appreciated.


    I must assume a few things, because your post is not complete enough.

    <FORM NAME="frmValues" ID="frmValues">
    <INPUT TYPE="text" NAME="tfValue1" ID="tfValue1">
    <BR>
    <INPUT TYPE="text" NAME="tfValue2" ID="tfValue2">
    </FORM>

    JavaScript:

    var strValue1 = document.frmValues.tfValue1.value;
    var strValue2 = document.frmValues.tfValue2.value;

    var strUrl = "http://www.helloworld.com/" + strValue1
    + "/" + strValue2;

    top.location = strUrl;

    HTH,

    Laurent
    --
    Laurent Bugnion, GalaSoft
    Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
    Private/Malaysia: http://mypage.bluewin.ch/lbugnion
    Support children in Calcutta: http://www.calcutta-espoir.ch
    Laurent Bugnion, GalaSoft, Oct 11, 2003
    #2
    1. Advertising

  3. paul544

    paul544 Guest

    "Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in message news:<3f87b8ce$>...
    > Hi,
    >
    > paul544 wrote:
    > > I need a script that will allow a user to enter variables into a form
    > > and then have a script generate a URL based on the input and then go
    > > there.
    > >
    > > I have an intranet. The address format is the same, but there are 2
    > > variables in the address that change. Normally the entire address
    > > must be typed in order to change what you want. I'd like to make it
    > > easier by just parsing input from two fields and put them in an
    > > address.
    > >
    > > Any help is appreciated.

    >
    > I must assume a few things, because your post is not complete enough.
    >
    > <FORM NAME="frmValues" ID="frmValues">
    > <INPUT TYPE="text" NAME="tfValue1" ID="tfValue1">
    > <BR>
    > <INPUT TYPE="text" NAME="tfValue2" ID="tfValue2">
    > </FORM>
    >
    > JavaScript:
    >
    > var strValue1 = document.frmValues.tfValue1.value;
    > var strValue2 = document.frmValues.tfValue2.value;
    >
    > var strUrl = "http://www.helloworld.com/" + strValue1
    > + "/" + strValue2;
    >
    > top.location = strUrl;
    >
    > HTH,
    >
    > Laurent


    Thanks! Considering how little info I gave, you nailed it. Thanks a bunch.
    paul544, Oct 11, 2003
    #3
  4. paul544

    paul544 Guest

    "Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in message news:<3f87b8ce$>...
    > Hi,
    >
    > paul544 wrote:
    > > I need a script that will allow a user to enter variables into a form
    > > and then have a script generate a URL based on the input and then go
    > > there.
    > >
    > > I have an intranet. The address format is the same, but there are 2
    > > variables in the address that change. Normally the entire address
    > > must be typed in order to change what you want. I'd like to make it
    > > easier by just parsing input from two fields and put them in an
    > > address.
    > >
    > > Any help is appreciated.

    >
    > I must assume a few things, because your post is not complete enough.
    >
    > <FORM NAME="frmValues" ID="frmValues">
    > <INPUT TYPE="text" NAME="tfValue1" ID="tfValue1">
    > <BR>
    > <INPUT TYPE="text" NAME="tfValue2" ID="tfValue2">
    > </FORM>
    >
    > JavaScript:
    >
    > var strValue1 = document.frmValues.tfValue1.value;
    > var strValue2 = document.frmValues.tfValue2.value;
    >
    > var strUrl = "http://www.helloworld.com/" + strValue1
    > + "/" + strValue2;
    >
    > top.location = strUrl;
    >
    > HTH,
    >
    > Laurent


    Oh, BTW, is there anyway to make the resulting URL launch in a new window?
    Thanks again.
    paul544, Oct 11, 2003
    #4
  5. Hi,

    paul544 wrote:
    > "Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in message news:<3f87b8ce$>...
    >
    >>Hi,
    >>
    >>paul544 wrote:
    >>
    >>>I need a script that will allow a user to enter variables into a form
    >>>and then have a script generate a URL based on the input and then go
    >>>there.
    >>>
    >>>I have an intranet. The address format is the same, but there are 2
    >>>variables in the address that change. Normally the entire address
    >>>must be typed in order to change what you want. I'd like to make it
    >>>easier by just parsing input from two fields and put them in an
    >>>address.
    >>>
    >>>Any help is appreciated.

    >>
    >>I must assume a few things, because your post is not complete enough.
    >>
    >><FORM NAME="frmValues" ID="frmValues">
    >><INPUT TYPE="text" NAME="tfValue1" ID="tfValue1">
    >><BR>
    >><INPUT TYPE="text" NAME="tfValue2" ID="tfValue2">
    >></FORM>
    >>
    >>JavaScript:
    >>
    >>var strValue1 = document.frmValues.tfValue1.value;
    >>var strValue2 = document.frmValues.tfValue2.value;
    >>
    >>var strUrl = "http://www.helloworld.com/" + strValue1
    >> + "/" + strValue2;
    >>
    >>top.location = strUrl;
    >>
    >>HTH,
    >>
    >>Laurent

    >
    >
    > Oh, BTW, is there anyway to make the resulting URL launch in a new window?
    > Thanks again.


    That would be something like:

    var g_wPopUp = null;

    function openPopUp()
    {
    var strValue1 = document.frmValues.tfValue1.value;
    var strValue2 = document.frmValues.tfValue2.value;

    var strUrl = "http://www.helloworld.com/" + strValue1
    + "/" + strValue2;

    if ( ( g_wPopUp == null )
    || g_wPopUp.closed )
    {
    var iWidth = WWW;
    var iHeight = HHH;
    var iLocX = ( screen.width - iWidth ) / 2;
    var iLocY = ( screen.height - iHeight ) / 2;
    var strFeatures = "width=" + iWidth
    + ",height=" + iHeight
    + ",screenX=" + iLocX
    + ",screenY=" + iLocY
    + ",left=" + iLocX
    + ",top=" + iLocY;

    g_wPopUp = open( strUrl, NAME, strFeatures );
    }
    else
    {
    g_wPopUp.location = strUrl;
    g_wPopUp.focus();
    }
    }

    Don't forget to replace WWW with the desired pop-up width, HHH with its
    height and NAME with a unique name.

    The function openPopUp could be called ONCLICk of a button in your form,
    for example.

    It's also nice to close the pop-up when the user leaves the page. This
    is done with (in the main window):

    <BODY ONUNLOAD="unloadMe();">

    and

    function unloadMe()
    {
    if ( ( g_wPopUp != null )
    && !g_wPopUp.closed )
    {
    g_wPopUp.close();
    }
    g_wPopUp = null;
    }

    HTH,

    Laurent
    --
    Laurent Bugnion, GalaSoft
    Webdesign, Java, JavaScript: http://www.galasoft-LB.ch
    Private/Malaysia: http://mypage.bluewin.ch/lbugnion
    Support children in Calcutta: http://www.calcutta-espoir.ch
    Laurent Bugnion, GalaSoft, Oct 12, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. michelle
    Replies:
    0
    Views:
    410
    michelle
    Jul 4, 2003
  2. Jeff Voigt

    Dynamic Control Creation w/Events?

    Jeff Voigt, Jul 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    365
    Natty Gur
    Jul 8, 2003
  3. Jon paugh
    Replies:
    1
    Views:
    701
  4. ^MisterJingo^

    url creation problem

    ^MisterJingo^, Sep 13, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    285
    Tarren
    Sep 13, 2006
  5. Just D.
    Replies:
    0
    Views:
    415
    Just D.
    Aug 11, 2004
Loading...

Share This Page