Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Form submission onload

    We will be passing values from one form page to another.
    This works OK, except that we would also like the second form page to submit automatically when the page is loaded, without the user pressing a submit button.

  • #2
    Regular Coder
    Join Date
    Jul 2003
    Location
    Massachusetts
    Posts
    472
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    <script type="text/javascript">
    	onload = function()
    	{
    		document.forms[0].submit();
    	}
    </script>
    Moderator @ WebDeveloper.com
    Mentor @ WebXpertz.net

  • #3
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Fred,

    I'll try it today and let you know.

  • #4
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not passing the variables to the next page.
    Here is the HTML we are using. Maybe I got
    the code in the wrong place?
    ======================
    <html>

    <head>
    <!--#4DBKInclude/header_en.htm-->
    <script language="Javascript">
    function getFromSearch() {
    var x = 0
    mySearch = location.search.substr(1).split("&")
    for (x=0;x<=mySearch.length;x++) {
    eval("document.forms.CustomerForm."+mySearch[x])
    }
    }
    </script>
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
    <meta name="generator" content="Microsoft FrontPage 5.0">
    <title></title>
    <!--#4DBKStoreSet/WMMW-->
    <!--#4DBKPrefsSet/CusErrorDuplicateAdd=ErrCustomerDupAdd.htm-->
    <!--#4DBKPrefsSet/CusErrorDuplicateUpd=ErrCustomerDupUpd.htm-->
    <!--#4DBKPrefsSet/CusErrorLocked=ErrCustomerLck.htm-->
    <!--#4DBKPrefsSet/CusErrorMode=PAGE--> <!-- can use POP instead of PAGE-->
    <script src="/Librairies/4DBKCheckValuesLib.js" language="Javascript"></script>
    <script src="/Librairies/4DBKConvertDataLib.js" language="Javascript"></script>
    <script src="/Librairies/4DBKSearchStringsLib.js" language="Javascript"></script>
    <script language="Javascript"><!--
    function CheckCustomerForm(form)
    { var error=false;

    if (!error) error=CheckEmpty(form.CusCode,form.CusCode.value,"Enter your code.");
    if (!error) error=CheckInSet(form.CusCode,"\\:/&,;","Some chars you've entered in the code field are not valid.");

    if (!error) error=CheckEmpty(form.CusPassword,form.CusPassword.value,"Enter your password.");
    if (!error) error=CheckInSet(form.CusPassword,"\\:/&,;@","Some chars you've entered in the password field are not valid.");
    if (!error) error=CheckMinLength(form.CusPassword,5,"The password you entered is either too short or too long. (5-10 characters)");

    if (!error) error=CheckEmpty(form.CusLastName,form.CusLastName.value,"Enter your name.");

    if (!error) error=CheckEmpty(form.CusEmail,form.CusEmail.value,"Enter your email address.");
    if (!error) error=CheckBadEMail(form.CusEmail,"The email address you've entered us not valid.");

    return(!error);
    }

    function WriteCustomerForm(form)
    { var cmd;
    cmd="4DBKExecute:";
    cmd=cmd+"4DBKStoreSet/WMMW;";
    cmd=cmd+"4DBKFieldSet/CusCode="+RemoveSemiColon(form.CusCode.value)+";";
    cmd=cmd+"4DBKFieldSet/CusPassword="+RemoveSemiColon(form.CusPassword.value)+";";
    cmd=cmd+"4DBKFieldSet/CusFirstName="+RemoveSemiColon(form.CusFirstName.value)+";";
    cmd=cmd+"4DBKFieldSet/CusLastName="+RemoveSemiColon(form.CusLastName.value)+";";
    cmd=cmd+"4DBKFieldSet/CusEmail="+RemoveSemiColon(ToLowerCase(form.CusEmail.value))+";";
    cmd=cmd+"4DBKFieldSet/CusLabel="+RemoveSemiColon(form.CusLabel.value)+";";
    cmd=cmd+"4DBKFieldSet/CusCountryMain="+RemoveSemiColon(form.CusCountryMain.value)+";";

    cmd=cmd+"4DBKGo/home_en.htm";
    window.top.location.href=cmd;
    return(true);
    }
    // -->
    </script>
    <link rel="stylesheet" type="text/css" href="Styles2.css">
    </head>

    <body onLoad="getFromSearch()">
    <script type="text/javascript">
    onload = function()
    {
    document.forms[0].submit();
    }
    </script> <div align="center">
    <center>

    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="500">
    <tr>
    <td align="center">
    <img src="../WebMediaFR/wm_mw100.gif" height="80" width="100" alt="WM-MW Logo" border="0"></td>
    <td align="center">
    <font size="5" face="Times New Roman">
    Enrollment Confirmed<br>
    </font><font size="4" face="Times New Roman" color="#CC0000">**
    Important, please read this entire page **</font><font size="4" face="Times New Roman">
    </font>
    </td>
    </tr>
    <tr>
    <td colspan="2">
    <p></p>

    <hr><p align="center">
    <font face="Arial" size="2">Thank you for joining.<br>
    Your enrollment has been confirmed by our system.<br>
    Please check your email in a few minutes as<br>
    it will contain important
    information on getting started.</font><p align="center">
    <b>
    <font color="#CC0000" size="3">You must click below or your store account<br>
    will not be created, and will cause delays.</font></b><form name="CustomerForm" enctype="application/x-www-form-urlencoded" method="POST" action="javascript:WriteCustomerForm(document.CustomerForm);" onsubmit="return CheckCustomerForm(document.CustomerForm);">
    <input name="CusCode" type="hidden" value="<!--#4DBKField/CusCode-->"><p align="center">
    <input name="CusPassword" type="hidden" value="<!--#4DBKField/CusPassword-->">
    <input type="hidden" value="<!--#4DBKField/CusFirstName-->" name="CusFirstName">
    <input name="CusLastName" type="hidden" value="<!--#4DBKField/CusLastName-->">
    <input type="hidden" value="<!--#4DBKField/CusEmail-->" name="CusEmail">
    <input type="hidden" value="<!--#4DBKField/CusCountryMain-->" name="CusCountryMain">
    <input type="hidden" value="<!--#4DBKField/CusLabel-->" name="CusLabel">
    <input type="submit" value="You must click here to finalize your enrollment"></p>
    </form>
    <p align="center"><font face="Arial"><font size="2">If you have any questions or problems, you can email
    <br>
    WM-MW Administration at: </font>
    <a href="mailto"><font size="2">admin@wm-mw.org</font></a></font><p align="center"><!--#4DBKInclude/copyrite.htm-->
    <p>
    <p>
    </td>
    </tr>
    </table>
    </center>
    </div>
    </body>

    </html>

  • #5
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <script type="text/javascript">
    onload = function()
    {
    document.forms[0].submit();
    }
    </script>

    Needs to be in the <head> of the second form page.

  • #6
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Tried that too, Willy.

    In the head, the page stays as is, with no
    submission.

  • #7
    New Coder
    Join Date
    Apr 2003
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Figured it out.

    All I did was take the line:

    document.forms[0].submit()

    and add it to the body tag:

    <body onLoad="getFromSearch(); document.forms[0].submit()">

    and it works perfectly!

    Thanks for the help!


  •  

    Posting Permissions

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