473,405 Members | 2,310 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

After timer submit form

Hi, im an absolute noob at javascript. I copied a timer from a site wich
counts to 5 minutes and then pos up an alert. Is it possibel to
automatically submit the form after I click ok ?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<SCRIPT LANGUAGE = "JavaScript">
<!--
var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
// Set the length of the timer, in seconds
secs = 300
StopTheClock()
StartTheTimer()
}

function StopTheClock()
{
if(timerRunning)
clearTimeout(timerID)
timerRunning = false
}

function StartTheTimer()
{
if (secs==0)
{
StopTheClock()
// Here's where you put something useful that's
// supposed to happen after the allotted time.
// For example, you could display a message:
alert("De tijd is voorbij. Druk op ok en daarna op opslaan")
}
else
{
self.status = secs
secs = secs - 1
timerRunning = true
timerID = self.setTimeout("StartTheTimer()", delay)
}
}
//-->
</SCRIPT>

<body onLoad="InitializeTimer()" >

<h1> Header here</h1>
<p>text</p>
<form name="form1" method="post" action="">
<table width="100%" border="1">
<tr>
<td width="17%">positief</td>
<td width="83%"><div align="right">
<textarea name="positief" cols="100" rows="5"
id="positief"></textarea>
</div></td>
</tr>
</table>
</form>
</body>
</html>
Jul 23 '05 #1
2 3704


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled document</title>
</head>
<script type="text/javascript">

var timerID = null;
var startsecs = 10;
var secs;

function countdown()
{
window.status = secs-- + ' seconds remaining...';
if (secs < 0)
{
clearInterval(timerID);
if (confirm('Submit the form?'))
document.getElementById('form1').submit();
else timerinit();
}
}

function timerinit()
{
secs = startsecs;
countdown();
timerID = setInterval(countdown, 1000);
}

onload = timerinit;
onunload = function()
{
if (null != timerID)
clearInterval(timerID);
}

</script>
<body>

<h1> Header here</h1>
<p>text</p>
<form id="form1" name="form1" method="post"
action="javascript:alert('submitted')">
<table width="100%" border="1">
<tr>
<td width="17%">positief</td>
<td width="83%"><div align="right">
<textarea name="positief" cols="100" rows="5"
id="positief"></textarea>
</div></td>
</tr>
</table>
</form>
</body>
</html>

Gave the user an opportunity to recycle the timer - you can replace
those lines with:

clearInterval(timerID);
alert('De tijd is voorbij. Druk op ok en daarna op opslaan')
document.getElementById('form1').submit();

Sorry, don't speak Dutch. Timers are annoying btw.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 23 '05 #2
> clearInterval(timerID);
alert('De tijd is voorbij. Druk op ok en daarna op opslaan')
document.getElementById('form1').submit();

Sorry, don't speak Dutch. Timers are annoying btw.


It's for an a social psychology experiment. People have 5 minutes to
complete a job in a small team. Then after these 5 minutes a newcomer is
introduced to the team. If someone would take longer to complete the task
the data cannot be compared. Otherwise I would agree .. timers are annoying
:-)

Floortje
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Paul Aspinall | last post by:
Hi I have an MDI app.... All child MDI windows are non-updateable... however, the users may leave the windows open... and there can be several of them. I want to implement a system to dispose...
7
by: Mike Eaton | last post by:
Hi All, I have a simple application that allows users to clock in and out and stores the data for use by the payroll department. It spends most of its life as a tray icon and when the user...
4
by: Rich P | last post by:
Greetings, I have a routine I was running in VB6 on a timed schedule. When the timeframe came up, the timer would be disable, the routine would run, and the timer gets enabled. I am trying to...
19
by: arunkumar_m2001 | last post by:
Can Somebody help me to code a timed test. Actually I want to implement a timer in a web application which will pop-up an alert automatically by refreshing the web page after a specific time. ...
1
by: jmgro | last post by:
I have spent way too much time trying to solve the following problem: I have a datalist with a timer in the footer template. It works wonderfully except when the user pages back, then forward,...
10
by: jason_box | last post by:
Hello, I was wondering if there was a way to have a javacript be activated by an input button that would call to a cgi program and querey every 10minutes and the cgi would update the page without...
4
by: sherifffruitfly | last post by:
Hi, I'm using StatusBar text to inform the user what's going on in the application. I pass a reference to from the main form's class to other (instances of) classes that are doing the actual...
4
by: vunet | last post by:
Hello, My HTML form submits some values to a hidden iframe. However, this is done for file upload fields only. After file uploading is finished I am using this form to submit all other data...
18
by: navyjax2 | last post by:
What if your event handler has to be nonstatic?
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.