Вот вариант с таймером. Теперь кнопки срабатывают по очереди, одна за другой с заданным интервалом. И проблема не решена.
<?php
if (isset($_POST['input_1'])) {
echo "1";
} elseif (isset($_POST['input_2'])) {
echo "2";
} else {
?>
<html>
<head>
<script type = 'text/javascript'>
seconds = 3;
var x = document.getElementsByTagName('form');
var secondsArray = [x.length];
function decreaseTime() {
for (var i = 1; i <= x.length; i ++) {
var button = document.getElementById('button_'+i);
//var form = document.getElementById('form_'+i);
if (secondsArray[i] > 0) {
secondsArray[i] -= 1;
button.value = secondsArray[i];
} else {
if (secondsArray[i] == 0) {
secondsArray[i] = -1;
button.click();
}
}
}
setTimeout('decreaseTime()',1000);
}
window.onload = function() {
for (var i = 1; i <= x.length; i ++) {
var button = document.getElementById('button_'+i);
button.value = seconds * i;
secondsArray[i] = seconds * i;
}
setTimeout('decreaseTime()',1000);
}
</script>
</head>
<body>
<form id = 'form_1' action = '' method = 'post' target = '_blank'>
<input type = 'hidden' name = 'input_1'>
<input id = 'button_1' type = 'submit' value = 'Submit' onsubmit="alert('A')">
</form>
<form id = 'form_2' action = '' method = 'post' target = '_blank'>
<input type = 'hidden' name = 'input_2'>
<input id = 'button_2' type = 'submit' value = 'Submit' onsubmit="alert('B')">
</form>
</body>
</html>
<?php
}
?>