Forum Moderators: open
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test Me</title>
<style type="text/css">
#mydiv { display:none; }
</style>
</head>
<body>
<h1 id="mainhead">Test Me</h1>
<div id="mydiv"></div>
<form method="post" id="myform" action="thispage.html">
<p><label for="title"> Enter a title:</label>
<input type="text" name="title" id="title" value=""></p>
<p><label for="mytext"> Enter some text:</label>
<textarea name="mytext" id="mytext" cols="12" rows="6"></textarea></p>
<p><input type="submit" value="Update"></p>
</form>
<script type="text/javascript">
//
window.onload=function() {
frm = document.getElementById('myform');
if (frm) { frm.onsubmit=function() { return writeMyStuff(); } }
};
//
function writeMyStuff() {
var hd = document.getElementById('mainhead');
var div = document.getElementById('mydiv');
var ttl = document.getElementById('title');
var txt = document.getElementById('mytext');
if (hd && div && ttl && txt) {
hd.innerHTML=ttl.value;
div.innerHTML = txt.value;
div.style.display='block';
}
return false;
}
</script>
</body>
</html>
Most browsers support javascript unless the user has disabled it. The advantage of using javascript in this case is the ability to set cookies on the client. This allows you to populate the form with text that is customized for each user. I am guessing from your first post that this is what you want to do. Hope this helps.