Search code examples
javascripthtmlformssubmitgreasemonkey

"clicking" submit button with no ID using javascript


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?


Solution

  • The tagName for that element is INPUT; there are no elements with tag name submit. Try this:

    document.getElementsByName('REG_BTN')[0].click();