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

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

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

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.

©2018 Martin Webb