Results 1 to 13 of 13

Thread: Autosubmit html-forms???

  1. #1
    Join Date
    Jan 2004

    Post Autosubmit html-forms???


    Does anyone know how to autosubmit a form in HTML?

    I found this javascript-sample on the internet:

    <SCRIPT LANGUAGE="JavaScript">
    function submitForm(){

    If I could run it all by itself...make the code activate it in html or asp I would be very happy!

    I know I can activate the function through a form or a href-link, but I need the code itself to trigger it, and submit to itself....

    Anybody know?

    Maybe any other way to do this?


  2. #2
    Join Date
    Nov 2003
    Aachen, Germany

    What would be the use of it? No user had a chance to enter data, so it must be you to prefill the form. The data for prefilling are already known to you, so why send them?

    Btw - you can call the function in your body tag:

    <body onload="submitForm()">

    This would only work (using the code of your function), if the name attribute of your form is name="form"...

    Cheers - Pit

    Edit: sorry, when pasting your function call, I grabbed a "{" which had to be removed...
    Last edited by Pittimann; 01-19-2004 at 10:33 AM.

  3. #3
    Join Date
    Jan 2006

    I found a use for it!

    Hey guys, hope you don't mind me jumping on the back of your little discussion there- however long ago it might have been!

    In answer to Pittiman's question:

    "What would be the use of it? No user had a chance to enter data, so it must be you to prefill the form. The data for prefilling are already known to you, so why send them?"
    ...my response is this:

    I'm using a thrid-party web-service for auto-response e-mail and newsletter services.

    Normally a user enters their info into a form and clicks submit. This gets sent to the third-party who send my user back to my site to a pre-defined landing page set by me (i.e.

    Thing is, I'm trying to take my data-collection to another level!

    I have a new-user registration form, part of which is the classic 'Tick here to get our newsletter'

    When they submit the form, all of their data is inserted into MY database for my use for everything my web-system is doing, but if 'optIN' is set to 1, I send them to an invisible page that sends their name and e-mail to the third-party, who then sends the usr back invisibly... nice!

    For anyone who wants it, my invisible auto-submitted form looks like this:

    PHP Code:
    // initialise the session:
    // I set $_session['optIn'] when they first entered their info,
    // as well as email and names (see below)
    // ...I call it now!
    if (($_SESSION['optIn']==0)||(!isset($_SESSION['optIn'])))
            // user requested to NOT be added to the newsletter
            // send them to the page the 3rd-party service provider sends them to:
        header("Location: editPersonal.php");
    else {
        // run the page!
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <title>You're Not Gonna See This!</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

    <body onload="submitForm()">
    <form method="post" action="http://www.thirdPartyServiceProvider.whatever" name="myForm" id="myForm">
    IMPORANT NOTE: DO NOT re-name the form- it is called by the name 'myForm'!
    <input type="hidden" name="whatever" value="1234" />
    <input type="hidden" name="redirect" value="http://www.backtomysite.com/editPersonal.php" />
    <input type="hidden" name="meta_required" value="from,name" />
    <input type="hidden" name="meta_forward_vars" value="0" />
    <input type="hidden" name="name" value="<? echo $_SESSION['firstname']; ?> <? echo $_SESSION['lastname']; ?>" />
    <input type="hidden" name="from" value="<? echo $_SESSION['email']; ?>" />
    <!-- now send the form! -->
    <script type='text/javascript'>document.myForm.submit();</script>
    And that's it!

    Hope this helps!

    Coos Creations

  4. #4
    Join Date
    Dec 2003
    Bucharest, ROMANIA
    Hi Pittiman, long time no see... I was a little bit woried for you... Clean your PM, is full, I guess a lot of friends here tried to give you PM's...

  5. #5
    Join Date
    Jul 2006
    Hey guys I saw your thread in online without being a member of the forum but the replies were so good that I had to sign up and thank you for the information. Thanks for the script COOS the scenario you described is almost exactly the same as mine.


  6. #6
    Join Date
    Jul 2007

    Thumbs up

    Shot coos. Exactly what i was lookin for

  7. #7
    Join Date
    Nov 2008
    hi. this is exactly what i need. but i cant get it running. what did i wrong?

    if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

    mm_showMyFileName( __FILE__ );


    <table width="100%">
    <tr class="sectiontableentry1">
    <td width="100%">
    if (@$_SESSION['invalid_coupon'] == true) {
    echo "<strong>" . $VM_LANG->_('PHPSHOP_COUPON_CODE_INVALID') . "</strong><br />";
    if( !empty($GLOBALS['coupon_error']) ) {
    echo vmGet($GLOBALS, 'coupon_error', '')."<br />";
    // If you have a coupon code, please enter it here:
    $checkout_this_step = is_array($_REQUEST['checkout_this_step']) ? $_REQUEST['checkout_this_step'][0] : $_REQUEST['checkout_this_step'];
    echo $VM_LANG->_('PHPSHOP_COUPON_ENTER_HERE') . '<br />';
    <form action="<?php echo $mm_action_url . basename( $_SERVER['PHP_SELF']) ?>" method="post" onSubmit="return checkCouponField(this);">
    Coupon Code: <input type="text" name="coupon_code" id="coupon_code" value="Ccd7C9c1e" width="10" maxlength="30" class="inputbox" />
    if($checkout_this_step == 'ship_to_info')
    echo "<br />Coupon No.: <input type=\"text\" name=\"voucher_code\" id=\"coupon_code\" value=\"Ccd7C9c1e\" width=\"30\" style=\"width:300px\" maxlength=\"1000\" class=\"inputbox\" />\n";
    <input type="hidden" name="Itemid" value="<?php echo @intval($_REQUEST['Itemid'])?>" />
    <input type="hidden" name="do_coupon" value="yes" />
    <input type="hidden" name="option" value="<?php echo $option ?>" />
    <input type="hidden" name="page" value="<?php echo $page ?>" />
    <input type="hidden" name="user_id" value="<?php echo $_SESSION['auth']['user_id'];?>" />
    <input type="hidden" name="checkout_this_step[]" value="<?php echo $checkout_this_step;?>" />
    <input type="hidden" name="ship_to_info_id" value="<?php echo $_REQUEST['ship_to_info_id'];?>" />
    <input type="hidden" name="shipping_rate_id" value="<?php echo $_REQUEST['shipping_rate_id'];?>" />
    <br /><input type="submit" value="<?php echo $VM_LANG->_('PHPSHOP_COUPON_SUBMIT_BUTTON') ?>" class="button" />
    <script type="text/javascript">
    function checkCouponField(form) {
    if(form.coupon_code.value == '') {
    new Effect.Highlight('coupon_code');
    return false;
    return true;
    <script type='text/javascript'>document.coupon_code.submit();</script>

  8. #8
    Join Date
    Dec 2003
    Bucharest, ROMANIA
    I would not expect someone to unreveal this old thread. Would you be so kind and rather start a new thread and present your problem there, please?

    And post your HTML generated code, not your Joomla/php code, as the latest is irrelevant for the javascript matters.

  9. #9
    Join Date
    Mar 2009
    Hey man. You can do the following to autosubmit your form:

    <script languaje="JavaScript">
    function MiFuncion(){location.href=document.MiFormulario.submit()};
    <form action='http://www.MiPaginaWeb.com' name='MiFormulario'>
    <input type='hidden' name='Nombre' value='Valor'>

    Too easy, isn't it?
    Try it. I spend a lot of time to find it. I hope you enjoy my work.

  10. #10
    Join Date
    Jan 2013
    the form should be inserted inside body, and script can be execution body. so when page is loaded, it will be immediately executed:

        <form action="page.php"  method="post">
        <input type="text" name="example1" value="blabla" />
        <input type="submit" /></form>
        <SCRIPT LANGUAGE=JavaScript>document.forms[0].submit();</SCRIPT>

  11. #11
    Join Date
    Jan 2013
    or this one:

    Here is a working auto-submit method: when page is loaded, it will the form will be immediately autosubmited (the values can be inserted with php variables).
    <form action="page.php"  method="post">
    <input type="text" name="example1" value="<?php echo $variable1;?>" />
    <input type="text" name="example2" value="<?php echo $variable2;?>" />
    <input type="submit" />
    <SCRIPT LANGUAGE="JavaScript">document.forms[0].submit();</SCRIPT>

  12. #12
    Join Date
    Jan 2013
    Please administrator, delete my above posts, and leave this current one:

    Here is a working auto-submit method: when page is loaded, it will the form will be immediately autosubmited (the values can be set with php variables).
    <form action="page.php"  method="post">
    <input type="text" name="example1" value="<?php echo $_POST['something1'];?>" />
    <input type="text" name="example2" value="ANOTHER_YOUR_VALUE" />
    <input type="submit" />
    <SCRIPT LANGUAGE="JavaScript">document.forms[0].submit();</SCRIPT>
    for example, the $_POST['something1'] value is received from the previous real-user submited Form, and this form can add another input with ANOTHER_YOUR_VALUE.

  13. #13
    Join Date
    Oct 2013
    Can anyone tell me is an auto login link is possible with this?


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.15069 seconds
  • Memory Usage 2,991KB
  • Queries Executed 15 (?)
More Information
Template Usage (35):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (4)bbcode_code
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (13)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (13)postbit
  • (13)postbit_onlinestatus
  • (13)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates