Dynamic creation of URL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • paul544

    Dynamic creation of URL

    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.
  • Laurent Bugnion, GalaSoft

    #2
    Re: Dynamic creation of URL

    Hi,

    paul544 wrote:[color=blue]
    > 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.[/color]

    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.frmVal ues.tfValue1.va lue;
    var strValue2 = document.frmVal ues.tfValue2.va lue;

    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

    Comment

    • paul544

      #3
      Re: Dynamic creation of URL

      "Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_S PAM.ch> wrote in message news:<3f87b8ce$ 1_5@news.bluewi n.ch>...[color=blue]
      > Hi,
      >
      > paul544 wrote:[color=green]
      > > 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.[/color]
      >
      > 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.frmVal ues.tfValue1.va lue;
      > var strValue2 = document.frmVal ues.tfValue2.va lue;
      >
      > var strUrl = "http://www.helloworld. com/" + strValue1
      > + "/" + strValue2;
      >
      > top.location = strUrl;
      >
      > HTH,
      >
      > Laurent[/color]

      Thanks! Considering how little info I gave, you nailed it. Thanks a bunch.

      Comment

      • paul544

        #4
        Re: Dynamic creation of URL

        "Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_S PAM.ch> wrote in message news:<3f87b8ce$ 1_5@news.bluewi n.ch>...[color=blue]
        > Hi,
        >
        > paul544 wrote:[color=green]
        > > 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.[/color]
        >
        > 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.frmVal ues.tfValue1.va lue;
        > var strValue2 = document.frmVal ues.tfValue2.va lue;
        >
        > var strUrl = "http://www.helloworld. com/" + strValue1
        > + "/" + strValue2;
        >
        > top.location = strUrl;
        >
        > HTH,
        >
        > Laurent[/color]

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

        Comment

        • Laurent Bugnion, GalaSoft

          #5
          Re: Dynamic creation of URL

          Hi,

          paul544 wrote:[color=blue]
          > "Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_S PAM.ch> wrote in message news:<3f87b8ce$ 1_5@news.bluewi n.ch>...
          >[color=green]
          >>Hi,
          >>
          >>paul544 wrote:
          >>[color=darkred]
          >>>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.[/color]
          >>
          >>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.frmVal ues.tfValue1.va lue;
          >>var strValue2 = document.frmVal ues.tfValue2.va lue;
          >>
          >>var strUrl = "http://www.helloworld. com/" + strValue1
          >> + "/" + strValue2;
          >>
          >>top.locatio n = strUrl;
          >>
          >>HTH,
          >>
          >>Laurent[/color]
          >
          >
          > Oh, BTW, is there anyway to make the resulting URL launch in a new window?
          > Thanks again.[/color]

          That would be something like:

          var g_wPopUp = null;

          function openPopUp()
          {
          var strValue1 = document.frmVal ues.tfValue1.va lue;
          var strValue2 = document.frmVal ues.tfValue2.va lue;

          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.locati on = 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="unloa dMe();">

          and

          function unloadMe()
          {
          if ( ( g_wPopUp != null )
          && !g_wPopUp.close d )
          {
          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

          Comment

          Working...