Reputation: 665
Here is the submit button i would like to 'click' using javascript.
<input type="submit" name="REG_BTN" value="Submit Changes">
I am trying to use something along the lines of...
document.getElementsByTagName('submit')[0].click();
to 'click' the button, but it does not work. I am writing a script to run in browsers so i do not have the ability to change any of the aspects of the submit button. I am new to javascript so it may just be something simple that i am not picking up. Is there another way to achieve this?
Upvotes: 1
Views: 6873
Reputation: 27
If page is complete loading first, and use querySelector (CSS) and click.
'
if (document.readyState=='complete'){
document.querySelector('input[type*="submit"]').click();
}
'
Upvotes: 0
Reputation:
The tagName
for that element is INPUT
; there are no elements with tag name submit
. Try this:
document.getElementsByName('REG_BTN')[0].click();
Upvotes: 6