1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Autosubmitting HTML form -- anything besides Javascript?

Discussion in 'HTML & JavaScript' started by OTrap, Apr 15, 2014.

  1. OTrap

    OTrap Jr. VIP Jr. VIP

    Joined:
    Jul 12, 2008
    Messages:
    2,282
    Likes Received:
    1,051
    Since the form is in HTML, I assume this still fits in this forum.

    I have a form:

    Code:
    <form name="form">
    <input id="field" name="field" value="<?php print $somephp; ?>" />
    <input type="image" src="images/buttons.png" alt="Post!" />
    </form>
    Up to this point, I've been using a little Javascript to autosubmit it.

    Code:
    <script language="JavaScript">
    document.forms['form'].submit(0);
    </script>
    The problem is, some of the people who visit the page have Javascript disabled.

    So my question is this: Is there another way to auto-submit the form without Javascript?

    Thanks!
     
  2. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,143
    You could use a meta redirect, since you know the submitted value beforehand.
     
  3. OTrap

    OTrap Jr. VIP Jr. VIP

    Joined:
    Jul 12, 2008
    Messages:
    2,282
    Likes Received:
    1,051
    What would that look like? My apologies, but I've never done much with METAs.
     
  4. MrBlue

    MrBlue Senior Member

    Joined:
    Dec 18, 2009
    Messages:
    950
    Likes Received:
    662
    Occupation:
    Web/Bot Developer
    You could use PHP to send the post request directly without using a form.

    Reference:
    Code:
    http://www.php.net/manual/en/httprequest.send.php