SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Passing Data from form to form

    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.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>

  2. #2
    SitePoint Addict
    Join Date
    Jul 2006
    Location
    Fionnphort, Isle of Mull, Scotland
    Posts
    349
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Confusing POST and GET ?

    I haven't analysed your code in any detail, so forgive me if I've misunderstood. Your JS seems to be appending something to a location (i.e. a URL), which is generally a GET, whereas your form's method is POST. Could this be where the problem lies ?

  3. #3
    SitePoint Member
    Join Date
    Apr 2006
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    not getting pls make it more clear...

  4. #4
    SitePoint Member
    Join Date
    Oct 2005
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the responses. I get the 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. I've spent hours trying to solve this problem, any ideas would be very welcome.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •