0

How to convert this code below into Jquery?

document.getElementsByName("autosubmit")[0].click(); // SUBMIT FORM

It should look like this code below.

$("#dateForm").submit();

Element Name is from <input type="submit" name="autosubmit">

Any help please.

asked Jan 12, 2014 at 16:04

4 Answers 4

2

Give your form an id and submit with:

$("#yourFormId").submit();
answered Jan 12, 2014 at 16:07
Sign up to request clarification or add additional context in comments.

Comments

0

You can use Attribute Equals Selector [name="value"]

$('input[type="submit"][name="autosubmit"]').trigger('click');

OR

If you have multiple elements with name=autosubmit you can use :first selector

$('input[type="submit"][name="autosubmit"]:first').trigger('click');

As per comment

setTimeout(function(){
 $('input[type="submit"][name="autosubmit"]').trigger('click');
}, 2000);
answered Jan 12, 2014 at 16:07

3 Comments

you can just use $('input[name="autosubmit"]').trigger('click');
@satpal How to set the timer before the trigger? I want to delay the trigger for just a 2 seconds.
@user3097736, Use setTimeout(function(){ $('input[type="submit"][name="autosubmit"]').trigger('click'); }, 2000);
0

try

$("input[name='autosubmit']").submit();
answered Jan 12, 2014 at 16:07

Comments

0

Try this code below:

$('input[name=autosubmit]:eq(0)').click();
Afzaal Ahmad Zeeshan
15.9k14 gold badges61 silver badges106 bronze badges
answered Jan 12, 2014 at 16:07

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.