PDA

View Full Version : manual submit with confirmation and auto submit without confirmation



serious1234
08-13-2009, 03:12 AM
i need to make this script ask users of confirmation when pushing submit button but when time is over i need the script to bypass submit confirmation and submit form automatically without confirmation. this is the script


<html>

<head>
<script type="text/javascript">
<!--


function changeText2(){
var userInput = document.getElementById('userInput').value;
}
/* this is to show live time */

function show2(){
if (!document.all&&!document.getElementById)
return
thelement1=document.getElementById? document.getElementById("tick3"): document.all.tick2
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
var seconds=Digital.getSeconds()
var dn=" pm"
if (hours<12)
dn=" am"
if (hours>12)
hours=hours-12
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
var ctime=hours+":"+minutes+dn
thelement1.innerHTML=ctime
setTimeout("show2()",1000)
}
window.onload=show2
function changeColour(elementId) {
var interval = 1000;
var colour1 = "#ff0000"
var colour2 = "#ffffff";
if (document.getElementById) {
var element = document.getElementById(elementId);
element.style.color = (element.style.color == colour1) ? colour2 : colour1;
setTimeout("changeColour('" + elementId + "')", interval);
}
}
// check multiple radio buttons
var ips,ckd;
var RadAry=new Array();
var GrpAry=new Array();
var str=new Array();
var answer=new Array();
function CheckRadio(){
ips=document.getElementsByTagName('INPUT');
RadAry=new Array();
for (i=0;i<ips.length;i++){
if (ips[i].type=='radio'){
RadAry[RadAry.length]=ips[i];
}
}
GrpAry=new Array();
GrpAry[0]=new Array();
for (i2=0;i2<RadAry.length;i2++){
GrpAry[GrpAry.length-1][GrpAry[GrpAry.length-1].length]=RadAry[i2];
if (RadAry[i2+1]&&RadAry[i2+1].name!=RadAry[i2].name){ GrpAry[GrpAry.length]=new Array();
}
}
for (i3=0;i3<GrpAry.length;i3++){
ckd=1;
for (i4=0;i4<GrpAry[i3].length;i4++){
if (GrpAry[i3][i4].checked==true){
ckd=0
}
}
if (ckd){

str = str + [i3+1]+" , " ;
}
}
if (str !=""){
str="Questions "+str+" not done";}
document.getElementById('error').innerHTML = str;
changeColour('error');
;str="";
}

//-->
</script>
</head>
<table width=150 bgcolor=#ffffff><tr><td>
now: <span id=tick3></span>
</head>
<body onload="changeText2()" bgcolor="#99CCCC">
<div id='userInput' value="0:0:5" /></div>
time left: <span id=tick2></span></td></t9r></table>
<?
if(isset($_POST['submit1'])){
$radio=$_POST['aqeel'];
print "value ".$radio; exit;}
?>
<form name="myform" method="POST" action="111.php" >
<input type="radio" name="aqeel" value="1">1</imput><br>
<input type="radio" name="aqeel" value="2">2</imput>
<input type='submit' value='Finish' name='submit1' ><!-- submit button should have submit as name lots of problems-->

<script language="javascript" type="text/javascript">
<!--
/*Time limit script- JavaScript Kit (http://www.javascriptkit.com) Over 200+ free JavaScripts here!*/
//enter limit in "minutes:seconds" Minutes should range from 0 to inifinity. Seconds should range from 0 to 59
var limit=document.getElementById('userInput').value;
thelement=document.getElementById? document.getElementById("tick2"): document.all.tick2
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*3600+parselimit[1]*60+parselimit[2]*1
}
function submitForm() {
document.forms["myform"].submit();
}
function begintimer(){

if (!document.images)
return
if (parselimit==1){
//window.location="exam.php?ex=finished"
submitForm(); }
else{
parselimit-=1;
curhr=Math.floor(parselimit/3600)
curmin=Math.floor(parselimit/60)
curmin=curmin-(curhr*60)
cursec=parselimit%60
if (curhr!=0){
curtime=curhr+" hr: "+curmin+" min: "+cursec+" sec"}
else {if (curmin!=0)
curtime=curmin+" min: "+cursec+" sec"
else
curtime=cursec+" seconds left" }
//window.status=curtime

setTimeout("begintimer()",1000)
thelement.innerHTML="<b style='font-size:14;color:red;'>"+curtime+"</b>"
}
}
begintimer();
//-->


</script>

</body>

</html>