简体   繁体   中英

auto submit form in drupal

I'm using drupal.

I have a form which has a single field, the field value increments 1 everytime the form is submitted. The form has a time until it expires, the time is resest every time the form is submitted

Im trying to build a module which will do more, but for a starting point I'm looking at getting the form to auto submit.

The form can be submitted by a random user, and will be with in 1-10 seconds of the form closing.

if anybody can give me anything at all to work with i'd be very greatful.

Thanks

You'll need to use javascript (I've used jQuery as it's included with Drupal):

drupal_add_js("
  (function($) {
    window.setTimout(function(){ $('#my-form-id').submit(); }, 5000)
  })(jQuery);
", 'inline');

Just change the 5000 to the number of milliseconds you want until the form auto-submits.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM