Reply
Passing Data from One Form to Another
Old 07-26-2006, 04:15 PM Passing Data from One Form to Another
Novice Talker

Posts: 5
It took me awhile but I was able to pass information from textboxes on a form on one page to textboxes on a form on a second page. It works fine, but when try to submit the form information on the second page (recipient) to the server I get an error: "Referring form output.htm?name=name&email=email&submit=submit does not exist". Page 1 is "formtest1.htm" and page 2 is "output.htm". I Can't find what's causing this error. Could anyone take look at the two pages below and give some idea of what's wrong? Thanks.
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>
</html>
__________________________________________________ ___________
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="http://www.jrclancy.com/thankyou.htm">
<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.leng th),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>
toptiger is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-26-2006, 05:38 PM Re: Passing Data from One Form to Another
funkdaddu's Avatar
Web Design Snob

Posts: 636
Change the name of your submit button. There is a form function called submit(), the browser gets confused. I changed it to submitButton and then changed your last line to:
Code:
document.form1.submit();
or
Code:
document.forms['form1'].submit();
to call the submit function and it worked. You need document.forms not just document.form to call it by name.

Last edited by funkdaddu : 07-26-2006 at 05:42 PM.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 07-27-2006, 09:07 AM Re: Passing Data from One Form to Another
Novice Talker

Posts: 5
Thanks for your suggestion. Unfortunately, I still get the same error message on form 2 when I try to submit to the server. Please understand that this occurs when I enter name and email information on form1 (formtest1.htm) and pass the information 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.
toptiger is offline
Reply With Quote
View Public Profile
 
Old 07-27-2006, 11:48 AM Re: Passing Data from One Form to Another
funkdaddu's Avatar
Web Design Snob

Posts: 636
Uh, after looking at your live version on your site (http://www.jrclancy.com/formtest1.htm) - the error "Referring form output.htm?name=name&email=email&submit=submit does not exist" is a Perl error from the script you are submitting to - not a JS error. I have no clue what the Perl code is so I can't give you any help. But why are you submitting a form to another form? Why not just submit the form directly to the script?
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 07-27-2006, 04:59 PM Re: Passing Data from One Form to Another
Novice Talker

Posts: 5
Thanks for the followup

You mau be right, but if that's the case why does form2 (output.htm) work perfectly when to send it alone to the pl script (after typing in the data). If I'm able to pass the data from form1 to form2 it seems to me it should work.
toptiger is offline
Reply With Quote
View Public Profile
 
Old 07-27-2006, 07:23 PM Re: Passing Data from One Form to Another
funkdaddu's Avatar
Web Design Snob

Posts: 636
OK, I see, but if form2 works - why even have form1? From my point of view, we're trying to fix a script you don't even need...

Last edited by funkdaddu : 07-27-2006 at 07:29 PM.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 07-28-2006, 08:16 AM Re: Passing Data from One Form to Another
Novice Talker

Posts: 5
I need to position a very simple form on a page with very limited space and then, on submit, have the user be directed to another page where we can collect additional data. It's a layout problem and there's not a lot of flexibility.
toptiger is offline
Reply With Quote
View Public Profile
 
Old 07-28-2006, 02:10 PM Re: Passing Data from One Form to Another
funkdaddu's Avatar
Web Design Snob

Posts: 636
Ok, that makes sense... try this:
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Untitled Page</title>
		<script type="text/javascript"><!--
window.onload = function() {
	queryString = location.search.slice(1);
	dataSets = queryString.split("&");
	if (dataSets != "") {
		sentData = new Array();
		for (i in dataSets) {
			sentData[dataSets[i].split("=")[0]] = dataSets[i].split("=")[1];
		}
		document.form1.yourname.value = sentData["name"];
		document.form1.email.value = sentData["email"];
	}
}
//-->
</script>
	</head>

	<body bgcolor="#ffffff">
		<form action="/cgi-bin/fmail.pl" method="post" name="form1">
			<input type="hidden" name="recipient" value="blah@blah.com"> <input type="hidden" name="subject" value="Question Form 1.0"> <input type="hidden" name="thankurl" value="thankyou.htm">
			<p><input type="text" name="yourname" 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>
	</body>

</html>
One think to take care in is not to name your inputs "name" or any other object attribute. If you call document.form1.name it's thinking your are requesting the name of the form, not the object "name". I renamed your input to "yourname". The same thing with your submit button. There is a form function called submit. If you call document.form1.submit is it the function or the input field? These types can cause problems later on, it may be why your form didn't work with your old script.

Last edited by funkdaddu : 07-28-2006 at 02:14 PM.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Old 07-29-2006, 09:57 AM Re: Passing Data from One Form to Another
Novice Talker

Posts: 5
No, that doesn't work. Same error message. Perhaps it is the perl script after all.
toptiger is offline
Reply With Quote
View Public Profile
 
Old 07-29-2006, 12:29 PM Re: Passing Data from One Form to Another
funkdaddu's Avatar
Web Design Snob

Posts: 636
It's the Perl script. if I turn of JS, it still craps out. One thing I noticed is that if you fill out the form from output.htm, it works, but output.htm?name=Name&username=Email&submit=Submit (like from the previous formtest1.htm ) gives an error. I think the Perl script is looking up the referring URL, and because it has a querystring attached to it it gets confused... sounds like the pl script to me.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Reply     « Reply to Passing Data from One Form to Another
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.17182 seconds with 12 queries