Ryan Angelo 0 Newbie Poster

I have a basic html here, where you could just submit the button through an action page, so it inserts the record into the mysql database in phpmyadmin, what I want to know is how to make it auto submit after 5 mins, while setting the blanks fields value into "0" in the database. I am currently using wamp as my local server. Is there a best way how to do this? like using javascript or ajax?

this is the html code

<h2><font size="6s">GHS Applicant Assessment Tool</font></h2> <h5><font size="5s"><p>This exam is an assessment tool to help us place you 

in the correct account. 

</p></font></h5> <p style="color:red;">* Required</p><br> <form name="quiz" id="myquiz" onsubmit="return validate()" method="post" 

action="/ghs/ghsadd.php"> <font size="5">Last name*</font><br> <input type="text" name="last_name" required><br> <font size="5">First name*</font><br> <input type="text" name="first_name" required><br> <font size="5">Middle Initial</font><br> <input type="text" name="middle_initial" required><br> <font size="5"><p class="thick">Highest Educational Attainment*</p></font> <font size="5"><input type="radio" name="educ_attain" value="hsalsgrad" 

required> High School 

Graduate / ALS Graduate<br> <input type="radio" name="educ_attain" value="shsgrad" required> Senior High 

School Graduate<br> <input type="radio" name="educ_attain" value="undergrad1" required> College 

Undergraduate 1 year<br> <input type="radio" name="educ_attain" value="undergrad2" required> College 

Undergraduate 2 years<br> <input type="radio" name="educ_attain" value="undergrad3" required> College 

Undergraduate 3 years<br> <input type="radio" name="educ_attain" value="undergrad4" required> College 

Undergraduate 4+ years<br> <input type="radio" name="educ_attain" value="collegegrad" required> College 

Graduate<br> </font><br> <hr> <font size="5"><p class="thick">Logic and Reasoning</p></font> <p>You will be given 5 minutes to complete this portion.</p><br> <font size="5"><p>The 4:25 P2P bus takes 1 hour and 45 minutes to arrive in 

Trinoma. If Joseph takes this bus, what time will he arrive in Trinoma? *</p> <input type="radio" name="logic1" value="0" required> 7:05 <br> <input type="radio" name="logic1" value="0" required> 6:25<br> <input type="radio" name="logic1" value="1" required> 6:10<br> <input type="radio" name="logic1" value="0" required> 5:55<br> <br> <p>Janine’s shoes cost $44.50, her pants cost $20.80 and her t-shirt

cost $14.95. What is the total of her purchases? *</p> <input type="radio" name="logic2" value="0" required> 85.25<br> <input type="radio" name="logic2" value="1" required> 80.25<br> <input type="radio" name="logic2" value="0" required> 82.55<br> <input type="radio" name="logic2" value="0" required> 80.55<br> <br> <p>Which number represents the smallest amount? *</p> <input type="radio" name="logic3" value="0" required> 1/12<br> <input type="radio" name="logic3" value="0" required> 2/9<br> <input type="radio" name="logic3" value="0" required> 15/200<br> <input type="radio" name="logic3" value="1" required> 3/140<br> </font> <br> <hr> <input name="submit" name="submitbutton" type="submit" value="Submit"> </input> </form> </div> </body> </html>

Ajax code to prevent the form from refreshing

$(function() {
function ajaxSubmit(form) {
type: form.attr('method'), // <-- get method of form
url: form.attr('action'), // <-- get action of form
data: form.serialize(), // <-- serialize all fields into a string that is 
ready to be posted 
to your PHP file
beforeSend: function(){
success: function(data){

$("#locForm").submit(function(e) {

setInterval(function() {
}, 10000);

code for autosubmitting every * seconds.

window.onload = function() {
var auto = setTimeout(function(){ autoRefresh(); }, 100);

function submitform(){
function autoRefresh(){
auto = setTimeout(function(){ submitform(); autoRefresh(); }, 10000);


Is their something that I missed why it was not working? I want to set the auto submit after 10 minutes, and automatically submit to the action-page, but also insert the record into database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.