I'm trying to use the solution from here to submit a form
using the link
it contains (instead of using the standard input
submit button)
<form id="form-id">
<button id="your-id">submit</button>
</form>
var form = document.getElementById("form-id");
document.getElementById("your-id").addEventListener("click", function () {
form.submit();
});
The form is a table of records that each have an 'E' link in the left-most column used to load the record for editing
<td style="text-align:center;">
<a id="a_edit_btn_#RecordId#">E</a>
</td>
and I would like to fire off the following when it is clicked
document.getElementById( $("a[id^='a_edit_btn_']").get(0).getAttribute("id") ).addEventListener("click", function () {
...
form.submit();
});
but get the following error
Uncaught TypeError: Cannot read property 'getAttribute' of undefined
Is it possible to use a selector in this way to obtain the Id attribute?