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

Q79 How can I store the form field values so I can use them again later?

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

Q79 How can I store the form field values so I can use them again later?

One answer to this question requires the use of frames. In the parent frame do something like this:

<html>
<head>
<script language="JavaScript"><!--
var userid = '';
var password = '';
//--></script>
</head>

<frameset rows="0,*">
    <frame src="about:blank" name="blank" frameborder="0" border="0">
    <frame src="logon.html" name="main" frameborder="0" border="0">
</frameset>

And then in the logon.html file:

<html>
<head>
<script language="JavaScript"><!--
function getparent() {
    document.logonForm.userid.value = parent.userid;
    document.logonForm.password.value = parent.password;
}

function setparent() {
    parent.userid = document.logonForm.userid.value;
    parent.password = document.logonForm.password.value;
}

//--></script>
</head>

<body onLoad="getparent()">

<form name="logonForm" onSubmit="return setparent();">
Userid: <input type="input" name="userid">
Password: <input type="password" name="password">
<p><input type="reset"> <input type="submit">
</form>

</body>
</html>

If you complete the form fields, press submit, then press reset, and then reload the bottom frame using reload frame, the form fields *should* reload from the parent frame using the onLoad event. You could if you wish use other events to trigger the population of the form.


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.