0

I am trying to create an adhoc code that save me pressing a repetitive button on a webpage, I opened F12 developer and tried using getElementbyID(..).click(); however didn't quite work, this is part extract of the button, I wonder if someone can advise what code I can use to automatically submit the button? Any help will be greatly appreicated. Best regards, Jon

mplungjan
  • 134,906
  • 25
  • 152
  • 209

1 Answers1

1

what code I can use to automatically submit the button

If this is for a regular form post without AJAX then you can select the form then use submit().

E.g.

/* 
 * The variable myform is previously determined such as by `document.forms[0]`
 * or a similar DOM selector method
 */
myform.submit();

If this is for a non-form button then use the click() method as suggested in the comments above. However, be aware that for this method there would have to be an Event Listener attached for the button to do anything of value.

seantunwin
  • 1,364
  • 12
  • 14