Form timeout auto submit

after time out the form will auto submit

Page 1 of 1

4 Replies - 8033 Views - Last Post: 23 May 2007 - 02:55 PM

#1 jilong  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 17-May 07

Form timeout auto submit

Posted 21 May 2007 - 11:56 PM

I would like to set the time limit for my html survey form, after the time limit the script will auto submit and redirect to the thanks page.

Below is the code i used. but it come out the error message "object does't not support the propperty or method."

can someone please help me on this, thanks

<script language="Javascript">
<!--
var countdown = "900"

function doCount() {
	if (countdown > 0) {
		countdown--
	}
	else {
	setTimeout('document.authenticate.submit()')
				document.location = "http://www.mypage.com/thank.html"
	}

window.status=countdown + " seconds left to complete the questionnaire."
setTimeout('doCount()',1000)
}

doCount()
//-->
</script>


<form name="authenticate">
..
..
..
	<input type="submit" value="Submit" name="submit">
	<input type="reset" value="Reset" name="reset">
</form>


This post has been edited by jilong: 22 May 2007 - 01:08 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Form timeout auto submit

#2 Oaty  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 28
  • Joined: 10-May 07

Re: Form timeout auto submit

Posted 22 May 2007 - 06:23 AM

I ran into this myself a while ago. If I remember right, you can't call submit on a form from Javascript, or because you have a button named "submit" the scripts confused. I believe that's your property error. A way around this is to call the click() method on your submit button:
setTimeout('document.authenticate.submit.click()')


That will act as if a user clicked the submit button.

On another note, your redirect will never happen! Once you submit a form, the browser is "redirected" to the page listed in your "action" property. The redirect should be the last thing done on the page/script that your action calls.
Was This Post Helpful? 0
  • +
  • -

#3 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Re: Form timeout auto submit

Posted 22 May 2007 - 09:20 PM

Hi.
Try this code it's simple
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script language="javascript">
countdown=900
function docount(){
if (countdown>0){
countdown--;
window.status=countdown + " seconds left to complete the questionnaire."
timer=setTimeout("docount()",1000)}
else{
clearTimeout(timer)
authenticate.submit()
document.location.href="../../All Users/Documents/My Pictures/Sample Pictures/Winter.jpg"
}
}
</script>
</head>

<body onload="docount()">
<form name="authenticate" method="POST" action="../../All Users/Documents/My Pictures/Sample Pictures/Blue hills.jpg">

	<input type="submit" value="Submit" name="any_thing_but_submit">
	<input type="reset" value="Reset" name="reset">
	<input type="text" name="T1" size="20"></form>
</body>
</html>


By the way don't ever set the name of any element within a form to "submit" when you need to use javascript to submit that form and that what you forgot about
Was This Post Helpful? 0
  • +
  • -

#4 jilong  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 17-May 07

Re: Form timeout auto submit

Posted 22 May 2007 - 11:27 PM

View PostOaty, on 22 May, 2007 - 06:23 AM, said:

setTimeout('document.authenticate.submit.click()')


That will act as if a user clicked the submit button.


Thanks Oaty it work. after i add the thank page to action the redirect work also :D

View Postahmad_511, on 22 May, 2007 - 09:20 PM, said:

Hi.
Try this code it's simple
By the way don't ever set the name of any element within a form to "submit" when you need to use javascript to submit that form and that what you forgot about


Hi ahmad i had try this code also, but it show me "object doesn't support for this property or method" for this line

clearTimeout(timer)


is be IE7 problem or i mess out something?
Was This Post Helpful? 0
  • +
  • -

#5 ahmad_511  Icon User is offline

  • MSX
  • member icon

Reputation: 131
  • View blog
  • Posts: 722
  • Joined: 28-April 07

Re: Form timeout auto submit

Posted 23 May 2007 - 02:55 PM

Hello..
I don't know what to say, But I have IE7 and there is no error occurres when running the script!...
But please double check if you still have a "submit" button with "submit" name;if you do try to rename it to any thing else.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1