Click to See Complete Forum and Search --> : Form data used to open new window


BrainDonor
11-19-2003, 05:06 PM
This is probably a really simple thing...but I've not worked with forms very much at all.

What I want to do is have a user enter a 6 character value (ASMITH) into a form and when they click the submit button, it takes that data they entered and appends .html to the end of it and then opens the new ASMITH.html page in a new window.

Any help that can be provided would be very, very appreciated!

Thanks guys!

Tom

Khalid Ali
11-19-2003, 07:02 PM
get value from the text field
suppose form name is
"form1" and text field name is "t1"
this is how you get the value from the tet feild and create a page name and open it in curent window

var value = document.form1.t1.value;
window.location.href=value+".html";

BrainDonor
11-21-2003, 11:34 PM
Thanks Khalid! I appreciate your help!

Tom

BrainDonor
12-23-2003, 12:54 PM
I'm having issues with the code below. Keep in mind that I am very new to forms...so please keep the laughter to a dull roar. :-)

What I want to do is take the value from the form and use it to open a new window with ".html" added on to whatever the user entered in the form. Thanks in advance for any help you can offer.

Tom

<HTML>
<HEAD>
<TITLE>Client Inquiry</TITLE>
<script>
var docvalue = document.form1.t1.value;
</script>
</HEAD>
<BODY>
<FORM NAME="form1" METHOD="get">
Enter Query Text: <INPUT TYPE="text" NAME="t1" size="18" maxlength="18">
<input type="submit" value="Get Info" class="button" onclick="window.location.href=docvalue+".html";">
</FORM>
</body>
</html>

BrainDonor
12-26-2003, 11:55 AM
Okay, I've tried to simplify this as best I can...see below.

Can anyone tell me what's wrong...or how I can accomplish this? Thanks guys.

Happy holidays.

Tom

<HTML>
<HEAD>
<TITLE>Test</TITLE>
<script>
var docvalue="/"+document.form1.t1.value+".html";
</script>
</HEAD>
<BODY>
<FORM NAME="form1">
Enter Query Text: <INPUT TYPE="text" NAME="t1" size="18" maxlength="18">
<input type="button" value="Get Info" onClick="window.open('docvalue','','')">
</FORM>
</body>
</html>

BrainDonor
12-26-2003, 01:32 PM
The code is working okay now...see below.

<HTML>
<HEAD>
<TITLE>Test</TITLE>
<script language="JavaScript">
function openWin()
{
var docvalue=document.form1.t1.value+".html";
window.open(docvalue,'','');
}
</script>
</HEAD>
<BODY>
<FORM NAME="form1">
Enter Query Text: <INPUT TYPE="text" NAME="t1" size="18" maxlength="18">
<input type="button" value="Get Info" onClick="openWin();">
</FORM>
</body>
</html>

russell_g_1
12-26-2003, 07:18 PM
It's probably better to do

<HTML>
<HEAD>
<TITLE>Test</TITLE>
<script language="JavaScript">
function openWin()
{
window.open(document.form1.t1.value + ".html",'','');
}
</script>
</HEAD>
<BODY>
<FORM NAME="form1" onsubmit="openWin()">
Enter Query Text: <INPUT TYPE="text" NAME="t1" size="18" maxlength="18">
<input type=submit value="Get Info">
</FORM>
</body>
</html>