General discussion

  • Creator
    Topic
  • #2130869

    Force a Submit on a form load?

    Locked

    by 3wadman ·

    How can you click a SUBMIT button using CODE?

    I would like to use a form POST or GET in a ASP page without needing the visitor to click the Submit button.

    In VB you can click any button by changing the VALUE of the object. Seems like either (windows.object.submit = True or document.all.object(1) = -1) VBSCRIPT or JSCRIPT should be able to trick the browser into sending its ‘pair values’ to another ASP page.

All Comments

  • Author
    Replies
    • #3546614

      Force a Submit on a form load?

      by b1xml2 ·

      In reply to Force a Submit on a form load?

      Try this:-


      Conditional Submission


      Search:


      Notes:-
      ——
      1. It is considered bad “form” (pun intended!) to submit forms without user action.
      2. The onchange event is used for input types:- text, password as well as select and textarea elements.
      3. The onclick event is used for input types radio and checkbox.
      4. Cross browser scripting would require you to check the type. If the supported browsers implement DOM properly, you can check the element.tagName instead of the element.type.
      Select elements have two values: select-one and select-multiple.
      5. To submit a form via code, use the document.formName.submit() method.
      6. It is good to have some validation, trimming leading and trailingspaces client-side. Saves work on the server.
      7. Regular Expression is supported in Javascript 1.2 and above. You would have to write your own function
      to trim values for older browsers using the substring and charAt methods.
      Regards,
      Brandon Driesen
      Senior Analyst Programmer

      • #3560008

        Force a Submit on a form load?

        by 3wadman ·

        In reply to Force a Submit on a form load?

        Sorry, this forces the user to gain and loose focus on the input box.

    • #3569228

      Force a Submit on a form load?

      by agibbs ·

      In reply to Force a Submit on a form load?

      To post a GET to an ASP page, just append the parameters to the URL, like so:

      http://www.blabla.com/mypage.asp?textbox1=name&textbox2=address&textbox2=city . . .

      To post a POST to an ASP page, use a JavaScript snippet something like so (assuming your form’s name was “form1”):

      –Aaron

      • #3560009

        Force a Submit on a form load?

        by 3wadman ·

        In reply to Force a Submit on a form load?

        That worked well, thanks!

        FYI: Form POST is the only easy way to securely send record set fields from a SQL to a SSL without the users knowledge.(You lose your seesion variables when you go from non-SSL to SSL)

    • #3560007

      Force a Submit on a form load?

      by 3wadman ·

      In reply to Force a Submit on a form load?

      This question was closed by the author

Viewing 2 reply threads