| View previous topic :: View next topic |
| Author |
Message |
skrabut
Joined: 22 May 2005 Posts: 5
|
Posted: Sun May 22, 2005 8:53 am Javascript: submit() problem |
|
|
|
I am having problems having my form submit when called in a script.
This works:
if((cmin2==0)&&(csec2==0))
{alert("This works!");}
else {down=setTimeout("DownRepeat()",1000)};
}
This does not work:
if((cmin2==0)&&(csec2==0))
{document.this_form.submit();}
else {down=setTimeout("DownRepeat()",1000)};
}
My form is marked as follows:
<form action="gradeassessment.asp" method="post" name="this_form">
Can anyone shed some light on my problem?
Thanks a head. |
|
degsy

Joined: 23 Feb 2005 Posts: 2440 Location: North East, UK
|
Posted: Sun May 22, 2005 8:56 am |
|
|
|
You need to post the full script and form.
You have variables that mean nothing and no function |
|
skrabut
Joined: 22 May 2005 Posts: 5
|
Posted: Sun May 22, 2005 9:04 am |
|
|
|
Here you go:
<script language=JavaScript>
var up,down;var min1,sec1;var cmin1,csec1,cmin2,csec2,theseminutes;
function Minutes(data) {
for(var i=0;i<data.length;i++)
if(data.substring(i,i+1)==":")
break;
return(data.substring(0,i));
}
function Seconds(data) {
for(var i=0;i<data.length;i++)
if(data.substring(i,i+1)==":")
break;
return(data.substring(i+1,data.length));
}
function Display(min,sec) {
var disp;
if(min<=9) disp=" 0";
else disp=" ";
disp+=min+":";
if(sec<=9) disp+="0"+sec;
else disp+=sec;
return(disp);
}
function Down(theseminutes) {
nMilliSeconds = ((theseminutes * 1000) * 60);
//oTimeOut = window.setTimeout("AutoSaveSubmit()",nMilliSeconds);
cmin2=1*Minutes(theseminutes);
csec2=0+Seconds("00");
DownRepeat();
}
function DownRepeat() {
csec2--;
if(csec2==-1) {
csec2=59; cmin2--;
}
//document.sw.disp2.value=Display(cmin2,csec2);
document.all.countdown.innerHTML=Display(cmin2,csec2);
if((cmin2==0)&&(csec2==0))
{document.this_form.submit();}
else {down=setTimeout("DownRepeat()",1000)};
}
// End -->
</script>
<form action="gradeassessment.asp" method="post" name="this_form" id=frmSubmit>
<div align='center'><table BORDER='0' CELLSPACING='0' CELLPADDING='0' width='90%'><tr><td><ol><li>У моей ÑеÑтры еÑть <input type='text' name='1|n|198|~|74' size='20' value='ключ' onkeypress='encrypt();'> (ключ).</li>
<li>У моей ÑеÑтры еÑть <input type='text' name='2|n|198|~|88' size='20' value='кольцо' onkeypress='encrypt();'> (кольцо).</li>
<li>У Саши еÑть <input type='text' name='3|n|200|.|74' size='20' value='ключ' onkeypress='encrypt();'> (ключ).</li>
</ol></td></tr>
</table>
<input type='submit' name='submit' value='Grade Exam'></div>
</form> |
|
degsy

Joined: 23 Feb 2005 Posts: 2440 Location: North East, UK
|
Posted: Sun May 22, 2005 9:17 am |
|
|
|
Hi,
So this is a timeout script?
What error do you get when it is supposed to submit? |
|
skrabut
Joined: 22 May 2005 Posts: 5
|
Posted: Sun May 22, 2005 10:01 am |
|
|
|
This is a timeout script.
I receive no errors when it tries to submit. As I mentioned in my first message, when I use an alert in place of the submit it fires off with no problems. |
|
degsy

Joined: 23 Feb 2005 Posts: 2440 Location: North East, UK
|
Posted: Sun May 22, 2005 10:59 am |
|
|
|
| What happens then if there is no error? |
|
skrabut
Joined: 22 May 2005 Posts: 5
|
Posted: Sun May 22, 2005 11:44 am |
|
|
|
| Nothing. The clock countsdown to zero and the page does not change. |
|
degsy

Joined: 23 Feb 2005 Posts: 2440 Location: North East, UK
|
Posted: Sun May 22, 2005 12:03 pm |
|
|
|
Not sure what's wrong.
Do you have an online version to test? |
|
skrabut
Joined: 22 May 2005 Posts: 5
|
Posted: Sun May 22, 2005 12:14 pm |
|
|
|
| I sent you a PM with instructions. Thanks for your assistance. |
|
ender
Joined: 02 Jun 2005 Posts: 1
|
Posted: Thu Jun 02, 2005 8:07 am |
|
|
|
| try replacing your input type="submit" with a href to javascript:submit(); |
|
|