HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Javascript: submit() problem
Post new topic   Reply to topic    HTML Help Forum Index -> Javascript
View previous topic :: View next topic  
Author Message
skrabut



Joined: 22 May 2005
Posts: 5

PostPosted: Sun May 22, 2005 8:53 am     Javascript: submit() problem Reply with quote

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

PostPosted: Sun May 22, 2005 8:56 am     Reply with quote

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

PostPosted: Sun May 22, 2005 9:04 am     Reply with quote

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>У моей сестры есть &nbsp;<input type='text' name='1|n|198|~|74' size='20' value='ключ' onkeypress='encrypt();'> &nbsp;(ключ).</li>
<li>У моей сестры есть &nbsp;<input type='text' name='2|n|198|~|88' size='20' value='кольцо' onkeypress='encrypt();'> &nbsp;(кольцо).</li>
<li>У Саши есть &nbsp;<input type='text' name='3|n|200|.|74' size='20' value='ключ' onkeypress='encrypt();'> &nbsp;(ключ).</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

PostPosted: Sun May 22, 2005 9:17 am     Reply with quote

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

PostPosted: Sun May 22, 2005 10:01 am     Reply with quote

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

PostPosted: Sun May 22, 2005 10:59 am     Reply with quote

What happens then if there is no error?
skrabut



Joined: 22 May 2005
Posts: 5

PostPosted: Sun May 22, 2005 11:44 am     Reply with quote

Nothing. The clock countsdown to zero and the page does not change.
degsy



Joined: 23 Feb 2005
Posts: 2440
Location: North East, UK

PostPosted: Sun May 22, 2005 12:03 pm     Reply with quote

Not sure what's wrong.
Do you have an online version to test?
skrabut



Joined: 22 May 2005
Posts: 5

PostPosted: Sun May 22, 2005 12:14 pm     Reply with quote

I sent you a PM with instructions. Thanks for your assistance.
ender



Joined: 02 Jun 2005
Posts: 1

PostPosted: Thu Jun 02, 2005 8:07 am     Reply with quote

try replacing your input type="submit" with a href to javascript:submit();
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> Javascript All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
DARFUR
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Link Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial