Forum Moderators: open

Message Too Old, No Replies

Form re-submits on Back Button

can I keep this page out of the history?

         

dawlish

11:07 pm on Mar 26, 2002 (gmt 0)

10+ Year Member



I have a form that is submitted onload after some variables are passed to it from another form.

The problem i have it that if the user clicks the back button on the browser from the confirmation page the form is submitted again.

Does anyone know of a way of preventing this from happening? Can I stop this page from being added to the history?

Any help is gratefully appreciated.

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title> Clients</title>
<link rel="stylesheet" type="text/css" href="../../css/style.css">

</head>

<body onLoad="document.formname.submit();">

<form NAME="formname" method="POST" action="/cgi-bin/cgiemail/jobsapply.txt">
<input type="hidden" name="Data" value="[Data]">
<input type="hidden" name="Instructions" value="[Instructions]">
<input type="hidden" name="success" value="/candidates/jobs/apply_success.shtml">
<INPUT TYPE="hidden" name="JOBTITLE">
<INPUT TYPE="hidden" name="JOBCODE">
<INPUT TYPE="hidden" name="username">
</FORM>
<SCRIPT LANGUAGE="JavaScript"><!--
function replace(string,text,by) {
// Replaces text with by in string
var i = string.indexOf(text), newstr = '';
if ((!i) ¦¦ (i == -1))
return string;
newstr += string.substring(0,i) + by;
if (i+text.length < string.length)
newstr += replace(string.substring(i+text.length,string.length),text,by);
return newstr;
}

var passed = replace(replace(location.search.substring(1),"+"," "),"=","&");

function split(string,text) {
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) ¦¦ (txtLength == 0)) return;
var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return;
if (i == -1) {
splitArray[splitIndex++] = string;
return;
}
splitArray[splitIndex++] = string.substring(0,i);
if (i+txtLength < strLength)
split(string.substring(i+txtLength,strLength),text);
return;
}

//--></SCRIPT>

<SCRIPT LANGUAGE="JavaScript1.1"><!--
function split(string,text) {
splitArray = string.split(text);
splitIndex = splitArray.length;
}
//--></SCRIPT>

<SCRIPT LANGUAGE="JavaScript"><!--
var splitIndex = 0, splitArray = new Object();

split(passed,'&');

for (var i=0; i < splitIndex; i=i+2) {
if (splitArray[i] == 'JOBCODE')
document.formname.JOBCODE.value = unescape(splitArray[i+1]);
if (splitArray[i] == 'JOBTITLE')
document.formname.JOBTITLE.value = unescape(splitArray[i+1]);
if (splitArray[i] == 'username')
document.formname.username.value = unescape(splitArray[i+1]);
}

//--></SCRIPT>
>

<p align="center"><b><font color="#FFFFFF" size="4">Processing.....</font></b></p>

</body>

</html>

tedster

3:38 am on Mar 27, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think you can immediately run a location.replace() after the submit runs and load a new version of the page without the onLoad="document.formname.submit();" in the BODY tag.