471,073 Members | 1,367 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,073 software developers and data experts.

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.
Jul 20 '05 #1
4 2734
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

Jul 20 '05 #2
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in message news:<3f**********@news.bluewin.ch>...
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.
Jul 20 '05 #3
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in message news:<3f**********@news.bluewin.ch>...
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.
Jul 20 '05 #4
Hi,

paul544 wrote:
"Laurent Bugnion, GalaSoft" <galasoft-LB@bluewin_NO_SPAM.ch> wrote in message news:<3f**********@news.bluewin.ch>...
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

Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Eddie de Bear | last post: by
5 posts views Thread by Tompa | last post: by
1 post views Thread by andrew queisser | last post: by
2 posts views Thread by charliewest | last post: by
2 posts views Thread by Dave Williamson | last post: by
15 posts views Thread by rwf_20 | last post: by
reply views Thread by Pascal Costanza | last post: by
13 posts views Thread by rn5a | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.