Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form | Q1696 [ previous next ]

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

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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.