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

Q918 How can I display the value of a form field in the document body when a form button is pressed?

You are here: irt.org | FAQ | DHTML | Q918 [ previous next ]

The following will work in Netscape Navigator 4 and Internet Explorer 4:

<script language="JavaScript"><!--
function changeContent(id,text) {
    if (document.all)
        document.all[id].innerHTML = text;
    else if (document.layers) {
        document.layers[id].document.open();
        document.layers[id].document.write(text);
        document.layers[id].document.close();
    }
}
//--></script>

<form>
<input type="text" name="fieldName">
<input type="button" value="Change" onClick="changeContent('firstname',this.form.fieldName.value)">
</form>

<div id="firstname"><layer id="firstname">xyz</layer></div>

©2018 Martin Webb