C
Clive Backham
I'm trying to dynamically modify the contents of a form (adding new
input fields in response to user actions). After the fields are added
and the form submitted, if the user then presses the Back button to
return to the form, the dynamically added fields may or may not be
present depending on the browser. Firefox 2.0.0.12 and Opera 9.10 keep
the fields, but IE 6.0 and Safari 3.0 lose them. I would like the
fields to be kept. I'm wondering if there is some action I'm failing
to perform after adding the extra field that is required to make the
change to the document persistent.
Here's a simplified version of the page:
<html>
<head>
<script type="text/javascript">
var counter=0;
function newfield()
{
counter++;
var xinp = document.createElement("input");
xinp.name = "newinput" + counter;
document.getElementById("sp1").appendChild(xinp);
// SHOULD I BE DOING SOMETHING ELSE HERE
// TO MAKE THE NEW FIELD SURVIVE A
// SUBMIT/BACK CYCLE?
}
</script>
</head>
<body>
<form action=test.jsp>
<input type=button value="add field" onclick="newfield()" />
<span id=sp1>
</span>
<input type=submit>
</form>
</body>
</html>
input fields in response to user actions). After the fields are added
and the form submitted, if the user then presses the Back button to
return to the form, the dynamically added fields may or may not be
present depending on the browser. Firefox 2.0.0.12 and Opera 9.10 keep
the fields, but IE 6.0 and Safari 3.0 lose them. I would like the
fields to be kept. I'm wondering if there is some action I'm failing
to perform after adding the extra field that is required to make the
change to the document persistent.
Here's a simplified version of the page:
<html>
<head>
<script type="text/javascript">
var counter=0;
function newfield()
{
counter++;
var xinp = document.createElement("input");
xinp.name = "newinput" + counter;
document.getElementById("sp1").appendChild(xinp);
// SHOULD I BE DOING SOMETHING ELSE HERE
// TO MAKE THE NEW FIELD SURVIVE A
// SUBMIT/BACK CYCLE?
}
</script>
</head>
<body>
<form action=test.jsp>
<input type=button value="add field" onclick="newfield()" />
<span id=sp1>
</span>
<input type=submit>
</form>
</body>
</html>