Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit problem when passing data between 2 forms

Status
Not open for further replies.

benhoa

Technical User
Oct 18, 2005
4
US
I am having a "submit" problem when passing name and email textbox information from form1 (formtest1.htm) to form2 (output.htm). After completing this info transfer when I click submit I get the error message: "Referring form output.htm?name=name&email=email&submit=submit does not exist"

However, form 2 submits perfectly if I simply keyword the info into form2 and click submit. So, the problem occurs only when I pass information from one form to another. Below are the 2 test forms that I have been using. I've spend hours trying to solve this problem, please help.

Form1 (formtest1.htm)

<FORM NAME="form1" ACTION="output.htm">
<p>
<INPUT TYPE="text" NAME="name" size="30" value="Name">
</p>
<p>
<INPUT TYPE="text" size="30" name="email" value="Email">
</p>
<p>
<INPUT TYPE="submit" name="submit" value="Submit">
</p>
</FORM>

</body>

Form 2 (output.htm)

<body bgcolor="#FFFFFF" text="#000000">
<FORM NAME="form1" method="post" action="/cgi-bin/fmail.pl">
<input type="hidden" name="recipient" value="tpearson@twcny.rr.com">
<input type="hidden" name="subject" value="Question Form 1.0">
<input type="hidden" name="thankurl" value="
<p>
<INPUT TYPE="text" NAME="name" size="30">
</p>
<p>
<INPUT TYPE="text" NAME="email" size="30">
</p>
<p>
<TEXTAREA NAME="comment"></TEXTAREA>
</p>
<p>
<INPUT TYPE="submit" name="submit" value="Submit">
</p>
</FORM>

<SCRIPT LANGUAGE="JavaScript"><!--
function getParm(string,parm) {
// returns value of parm from string
var startPos = string.indexOf(parm + "=");
if (startPos > -1) {
startPos = startPos + parm.length + 1;
var endPos = string.indexOf("&",startPos);
if (endPos == -1)
endPos = string.length;
return unescape(string.substring(startPos,endPos));
}
return '';
}

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(location.search.substring(1),"+"," ");

document.form1.name.value = getParm(passed,'name');
document.form1.email.value = getParm(passed,'email');
//--></SCRIPT>

<script language="JavaScript"><!--
document.form['form1'].submit;
//--></script>
</body>
 
The error would indicate that the file output.htm does not exist in the current directory. Are you certain it is there, that the name is correct or that the file is not in a different folder?

At my age I still learn something new every day, but I forget two others.
 
Yes, it is absolutely in the same folder and I've checked the name many times.
 
i've never heard of that javascript error in my life. do you have a link? what line is the error occurring on? and a line number would be useless - can you tell us the code that it's failing on? best would be to give us a link or, if not available, the entire code, so we can try it ourselves.



*cLFlaVA
----------------------------
[tt]somebody set up us the bomb![bomb][/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
and by the way, "name" is a javascript reserved keyword, as are "string" and "replace". i strongly suggest getting away from using these words as field names, function names, etc.

for example, this line will most likely crap out:

Code:
document.form1.name.value = getParm(passed,'name');

at the very least (if you MUST use "name" as a field name), do this:

Code:
document.forms['form1'].elements['name'].value = getParm(passed, 'name');



*cLFlaVA
----------------------------
[tt]somebody set up us the bomb![bomb][/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top