What I am trying to do is getting the same result as clicking on this following submit button.
<input id="submit_http:" class="add_submit" type="button" onclick="return dex.forms.form_ajax_submit(this,function(res) { alert('posting failed'); },function(res) { alert('posting success'); });" value="Next" name="submit_http:">
I was trying to do it like that:
$('.NextButton').click(function () {
dex.forms.form_ajax_submit(document.getElementsByName('submit_http:'),
function(res) {
alert('posting failed');
},
function(res) {
alert('posting success');
});
});
But looks like document.getElementsByName is not returning the same result
as the submit button ‘this’
How can I solve this issue?
The only actual mistake you made was using the function
document.getElementsByName, because it returns an array of elements (as indicated by the plural). What you need is a single element.Either access the first element of the array by using:
or use the already recommended and more precise function: