0

I have a page which loops though 15,000 entries importing them in to a database. After each 50 entries the user is presented with a continue button.

<form name="contine" method="post" action="<?php echo $continue?>">
 <input type="submit" name="Submit" value="Continue"></input>
</form>

This works well, as it slows the script down so it doesn't load the server (NAS drive running PHP4), and gets around the php page timeout.

$continue contains script name and the current position of the import, so after submission the page will start from there.

I'm trying to do this so the user doesn't need to sit there clicking continue after ever 50 entries. With 15,000 in total it's a lot of clicks.

I've tried using header('Location: '.$continue.'/'); This works if I only try importing around 3,000 entries, any more than that and Chrome complains about looping.

So I'm hoping I can just replace the input button with some javascript that will submit the form for me.

Is that possible and how would I do it ?

Thanks :)

Antony
15.2k10 gold badges48 silver badges76 bronze badges
asked Apr 18, 2013 at 7:54
2
  • How about forcing a press every x milliseconds? like so: setTimeout(function() { // force press or submit form again }, 500); Commented Apr 18, 2013 at 7:56
  • For the record, your HTML is invalid. Should be: <input type="submit" name="Submit" value="Continue" /> as input tag is self-closing. Commented Apr 18, 2013 at 8:02

3 Answers 3

1

Using plain JS, submit the form using (need to add id="continue" to the form):

document.forms["continue"].submit();

Using jQuery, you can submit the form using the following code:

$('form[name="continue"]').submit();
answered Apr 18, 2013 at 7:57
Sign up to request clarification or add additional context in comments.

Comments

0

You could add a oneliner that simply submits your form. additionally you can do this inside a timeout so the user can cancel the process.

answered Apr 18, 2013 at 7:58

Comments

0

You can put a sleep command in before the Location call, and also add in a random string get variable, with a time stamp as a value, so that browsers see a more distinct query string. Obviously your script can ignore the random get Variable...

answered Apr 18, 2013 at 7:59

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.