Passing Id attribute from a (JQuery) selector into (JavaScript's) document.getElementById() -
i'm trying use solution here submit form
using link
contains (instead of using 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 table of records each have 'e' link in left-most column used load record editing
<td style="text-align:center;"> <a id="a_edit_btn_#recordid#">e</a> </td>
and fire off following when clicked
document.getelementbyid( $("a[id^='a_edit_btn_']").get(0).getattribute("id") ).addeventlistener("click", function () { ... form.submit(); });
but following error
uncaught typeerror: cannot read property 'getattribute' of undefined
is possible use selector in way obtain id attribute?
forget hodge-podge mix of jquery , pure javascript - addeventlistener
code work on 1 element @ time, whereas jquery event handler can bound multiple elements @ once:
$("a[id^='a_edit_btn_']").on('click', function() { // id of clicked link in "this.id" var = this.id; form.submit(); });
that said - intent these multiple buttons cause form submit?
Comments
Post a Comment