Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1696 How can I update the action attribute of a form to include details from one of the form fields?

You are here: irt.org | FAQ | JavaScript | Form | Q1696 [ previous next ]

Use the onSubmit event handler to indirectly update the action attribute, for example:

<html>

<head>

<script language="JavaScript"><!--
function gotoURL(formReference){
  var newURL = 'http://www.somewhere.com/' + formReference.elements[1].value;
  formReference.action = newURL;
}
//--></script>

</head>

<body>

<form method="post" action="" onSubmit="gotoURL()">

<input type="hidden" name="login" value="login">
<input type="text" size="10">
<input type="submit" value="login">

</form>

</body>

</html>

©2018 Martin Webb