Skip Navigation

[Resolved] activate an action when loading a page with form, without submit

This support ticket is created 3 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+00:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by avansisI-2 3 years, 4 months ago.

Assisted by: Jamal.

Author
Posts
#1859495

Hi!

Is it possible activate an action when loading a page with form, without submit

I try with this javascript but doesnt work

document.forms[0].submit();
alert("enviado");
#1859539

Maybe I didn't make myself clear. I need to activate the send form action when the page loads without having to click on the send button

#1859899

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello and thank you for contacting the Toolset support.

What you are, probably, looking for is the submit function in jQuery. hidden link

If you have only one form inside the page you can use the following code:

// Passing our function to jQuery will execute it when the page loads
jQuery(function(){
  // submit the form
  jQuery('form').submit()
})

If you may have multiple forms on the page, you will need to scope the jQuery selector. For example, put the form inside a <div> that has the class "my-form" and use the following code:

// Passing our function to jQuery will execute it when the page loads
jQuery(function(){
  // submit the form
  jQuery('.my-form form').submit()
})

I hope this helps. Let me know if you have any questions.

#1859959

Thanks Jamal,

Where do I have to put that code? if I put it in the post-form it doesn't work.

Do I have to put it on the page? How do I add a js on the page?

#1859971

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

You can add it to the Javascript section(JS editor) of the form, check this screenshot hidden link

#1859981
Captura de pantalla 2020-11-28 a las 15.40.30.png

Thanks Jamal.

I added there but doesnt work it.

#1859995

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

I'll need to take a closer look at your form and where it is being used to understand why it is not working. If you would agree, your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#1860021

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.