Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a dynamic URL within a Form

Status
Not open for further replies.

ziggy00001

Programmer
Mar 11, 2002
17
0
0
CA
After evaluating whether the account number entered into a form input box by the user, is NOT a current account number(ie customer not in local db).
I need to be able to take this account number and use is it to create a dynamic URL which would then be sent to a server to be processed to retrieve the new customer's personal info.

What is the best way to either pass a variable from the javascript or the value of the input box and how can I do it.

Code:
<script language="javascript">
<!--
validate()
{
// If customer is in database, use account number to set to current customer
if (strAnswer == true)
	{
        // set customer
	strSetCustomer = rs("ID");
	qsBridge.FireEvent("SetCustomer", strSetCustomer);
	event.returnValue=false;
	}
}
//-->
        </script>
	</head>
	<body scroll="no" STYLE="position:absolute; top:0px; left:0px; width:100%; height:100%; padding:10px; font:bold 13pt verdana; color:white;
 filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=1, StartColorStr='#8eb6d9', EndColorStr='#000000')">
		<form name="accountID"  method="get" onsubmit="javascript:validate()" action="[URL unfurl="true"]http://url?p="[/URL][b]form text1 value, syntax?[/b]>
				Scan Tape ID :<input type=text name="text1" size="20">
				<input type=submit name="text2" Value="OK">
			</form>
			<script language="javascript" src="copy.js">
			</script>
			<script language="javascript">
				document.accountID.text1.focus();
			</script>

Thanks for everyones help.
 
If you're submitting the page, you can use the form's action method before the page is submitted to change what page it's submitted to:

document.formname.action = "someUrl.html"

or if you don't wanna submit, you can use the location method:

document.location = "someUrl.html"

I'm assuming you can easily build the string that contains the url of the new page.

-kaht

banghead.gif
 
So before my function validate() is finished I would insert
document.formname.action = "theurlIwanttogoto.html"
and delect action from the tag <form name="accountID" method="get" onsubmit="javascript:validate()">
 
you don't need to delete the current action argument in your form tag, it will be overwritten

-kaht

banghead.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top