0

I have a website with a Javascript button, that submits the code entered and refreshes the screen. This is on a open source application and it not my own code.

This button does the job most of the time, but I would like to "hook" into this feature if that is the correct terminology and auto refresh the submit at a specific interval.

<button id="dataRefreshButton" type="submit" title="Refresh with latest data." class="button capsule up">

I was wondering if there is a way to auto submit this code in some way?

1
  • You want to auto-submit at a specific interval? Commented Sep 14, 2012 at 9:01

2 Answers 2

3

something like setTimeout() and click():

<script type="text/javascript">
    setTimeout(function(){ document.getElementById('dataRefreshButton').click(); }, 5000); // 5 seconds
</script>

or setInterval():

<script type="text/javascript">
    setInterval(function(){ document.getElementById('dataRefreshButton').click(); }, 5000); // every 5 seconds
</script>
Sign up to request clarification or add additional context in comments.

1 Comment

This worked really well and I was surprised on how easy it was! Thanks for this.
0

See http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml for info on form submission.

As for specific intervals use either

setInterval(function() {/*you code*/}, time_interval);

or

function tick() {
    setTimeout(function() {tick(); /*you code*/}, time_interval);
};

with the submission along the lines of:

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

Comments

Your Answer

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.