Jump to content

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


Guest lenix

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. .

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.