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