1

i have the following form, i want to create a function to auto click on page load.

<form id="demo-form" method="post" action="http://demo.org/cad/original/core.php">
  <fieldset id="demo-user-chat">
    <label for="demo_chat">Message</label>
    <textarea name="demo_chat" id="demo_chat" rows="5" cols="50" onkeypress="if (typeof pressedEnter == 'function') return pressedEnter(this,event);" placeholder="Message" autocomplete="off"></textarea>

  </fieldset>


  <div id="demo-user-submit">
    <input type="submit" id="submitform" name="submit" class="submit" value="Submit">

  </div>
</form>
dhilt
  • 13,532
  • 6
  • 48
  • 67
mxboy
  • 33
  • 4
  • even tho is almost the same tittle is different because i can;t get it to work for my function, unless u have a better idea, thanks – mxboy Oct 29 '17 at 15:08
  • create a function to submit form by ajax request.then call the function on onload event. – Madhawa Priyashantha Oct 29 '17 at 15:10
  • As it stands... you don't have any code that even attempts a click? Also, you would normally not mimic a click, but instead capture the data in a form and perform the ajax call. What do you even gain by autoclicking the submission of a form on your own website on a page load? – Sumurai8 Oct 29 '17 at 15:13

1 Answers1

0

you can use .submit() :

Bind an event handler to the "submit" JavaScript event, or trigger that event on an element.

you code would be like :

$(window).load(function() {
     $('#demo-form').submit(function(){return true;});
});
M0ns1f
  • 2,637
  • 2
  • 12
  • 25