Jump to content

Using javascript to automatically triggered the submit button when the time limit is over.


Go to solution Solved by denno020,

Recommended Posts

I need some help in my code. All I want is after my timer reaches to zero it will automatically triggered the submit button.

My JSCode: <input id='timer' readonly>

<script>

var ct = setInterval('calculate_time()',100);

function calculate_time()

{

var end_time = '$_SESSION[start_time]';

var dt = new Date();

var time_stamp = dt.getTime()/1000;

var total_time = end_time - Math.round(time_stamp);

var mins = Math.floor(total_time / 60);

var secs = total_time - (mins * 60);

if(secs < 10){secs = '0' + secs;}

document.getElementById('timer').value = mins + ':' + secs;

 

if(mins <= 0)

{

if(secs <= 0 || mins < 0)

{

clearInterval(ct);

document.getElementById('timer').value = '00:00';

alert('TIME IS UP! To continue you should press OK Button');

document.location("PROCESS.PHP") ;<-----------------------ITS NOT WORKING!!!

}

}

}

</script>

Tnx for the help denno020. I have already solved my problem with this code : document.myform.submit(); - - -- -- - > my problem relies on the submission process (from $_POST(Button_name){} to $_POST only . . this problem was solved. Once again thank you so much for the help. 143 ALL. .

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.