JavaScript - Confirmation When Pressing Submit And Bypass That When Time Is Out
can anyone help me change this script to add confirmation of finishing the exam when pressing submit button and avoiding that when time is out....and how could i save radio button checked even if page being refreshed it stays checked....thanks in advance. this is the code....
Code: <?php if($_POST['submit']) { print_r($_POST); $aqeel= $_POST['q']; print "a ".$aqeel[2]; exit(0); } ?> <?php //Function to generate/fetch the exam //Example output of the function: $examQuestions = " <label for='q1'>What is your name?</label><input type='text' name='q[1]' id='q1'><br /> Are you:<label for='q2a'>Male</label><input type='radio' name='q[2]' id='q2a' value='male'> or <label for='q2b'>Female</label><input type='radio' name='q[2]' id='q2b' value='female'><br /><input type='text' name='c'> "; //Set a variable in the format: 'h, m, s' for use as the timer paramiters //Sample: $timerLength = '0, 0, 10'; //0 hours, 0 minutes, 10 seconds ?> <html> <head> <script language='javascript' type='text/javascript'> function timerShow(hours, minutes, seconds, init) { if(init === true) { setTimeout("timerTick(" + (hours * 360 + minutes * 60 + seconds) + ")", 1000); } if(hours > 0) { time_left = hours + " hr:" + minutes + " min:" + seconds + " sec"; } else { if(minutes > 0) { time_left = minutes + " min:" + seconds + " sec"; } else { if(seconds > 0) { time_left = seconds + " sec"; } else { document.getElementById("submit").click(); } } } document.getElementById("timer").innerHTML = "Time Remaining: <b style='font-size: 14pt; color:red;'>" + time_left + "</b>"; } function timerTick(seconds) { seconds -= 1; if(seconds > 0) { setTimeout("timerTick(" + seconds + ")", 1000); } hours = (seconds - (seconds % 360)) / 360; seconds -= hours * 360; minutes = (seconds - (seconds % 60)) / 60; seconds -= minutes * 60; timerShow(hours, minutes, seconds, false); } </script> </head> <body> <div> This exam consists of <b><?php echo $num_q; ?></b> questions.<br /><br /> You have <b></b> minutes to complete this exam.<br /><br /> <input type='button' onclick='this.parentNode.style.display = "none"; document.getElementById("exam").style.display = ""; timerShow(<?php echo $timerLength; ?>, true);' value='Start'> </div> <form id='exam' method='post' style='display: none;'> <div id='timer'></div> <?php //output the exam here echo $examQuestions; ?> <input type='submit' value='Finish' name='submit' id='submit'> </form> </body> </html> Similar TutorialsHey, I've got the following problem: I want to edit this code: <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.pp"><img src="http://blog.bastian.info/wp-content/uploads/2010/02/facebook-glossy-logo.jpg"></a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script> So that after they click the button that triggers the facebook share, 7 seconds after they click it, some text appear and the picture they click disappears. Cheers i need a function that count down until zero. how could i make it auto submit which is very important for me and accepts the choices which are as radio buttons instead of waiting for users to push submit button.
Hello, i need one script, which will remove the timer and i’ll be able to start download the file without waiting the time… Okay, i dont need such things… I need only one simple thing… Without any premium accounts… It should remove the timer (30 sec)… That’s everything i want… Link: *HIDEN* Thanks. Contact me via pm or skype - bahurz1 How can I simulate pressing a key in javascript into a specific textfield?
HI, I have a website with a Login page (no username only password required), but at the moment it only works when you click Login after entering the password. How could i make it so that pressing Enter will do the same???? here is the full index.html file Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Please login</title> <link rel="stylesheet" href="css/login.css" type="text/css" media="all" /> <!--[if IE 7]><link rel="stylesheet" href="css/style.ie7.css" type="text/css" media="screen" /><![endif]--> </head> <body> <div id="Main"> <div class="corner TL"></div> <div class="corner TR"></div> <div class="corner BL"></div> <div class="corner BR"></div> <div class="logo"></div> <div class="loginForm"> <form name="login-form"> <script language="javascript"> <!-- /*Change the usename,password and the page to redirect the user to to suit your own site*/ function login(form) { if (form.password.value=="england2000") { location="/en" } else { alert("Sorry Invalid Password") } } //--> </script> <label>PASSWORD</label> <input class="field" name="password" type="password" /> <input type="button" value="Login" class="loginB" onClick="login(this.form)"> </form> </div> <div style=" clear:both;"></div></div> </body> </html> Hi, I am facing one problem when i am trying to open the outlook express through javascript. Here i am able to open the outlook express with all the data, but when i press enter on any line of the body if the message, it moves 2 lines. Can any body help me to make it to single spacing. The code i have used is given below. sendemail.js Quote: // JScript File function EmailIt(task,issue_id,emailTO,strTitle,strsubsystem,chkAvailableAll,ddlJob,ddlSystem,ddlTester,ddlPr iority,txtDueDate,ddlAssignedTo,ddlStatus) { //win = window.open("...\\Issues\\HTMLPage3.htm"); var daReferrer = document.referrer; //var task = escape(document.URLUnencoded); //var issue_id = document.URLUnencoded.split("="); var email = emailTO; var title = strTitle; var subsystem = strsubsystem; var availableall = chkAvailableAll; var CustomerJob = ddlJob; var System = ddlSystem; var DueDate = txtDueDate; var AssignedTo = ddlAssignedTo; var Priority = ddlPriority; var Tester = ddlTester; var Status = ddlStatus; var subject = "Issue Task number is " + issue_id + " - " + escape(title) ; var body_message = " Your Assigned Task is.%0D " + escape(task); //+ escape("\n") + " :subsystem ===>"+ subsystem + escape("\n") + " :title ===>" + title + escape("\n") + "available all ===>" +availableall; body_message += escape("\n"); body_message += escape("\n"); body_message += " Customer/Job : " + escape(CustomerJob); body_message += escape("\n"); body_message += " Available For All : " + escape(availableall); body_message += escape("\n"); body_message += " System : " + escape(System); body_message += escape("\n"); body_message += " Sub System : " + escape(subsystem); body_message += escape("\n"); body_message += " Title : " + escape(title); body_message += escape("\n"); body_message += " DueDate : " + escape(DueDate); body_message += escape("\n"); body_message += " AssignedTo : " + escape(AssignedTo); body_message += escape("\n"); body_message += " Priority : " + escape(Priority); body_message += escape("\n"); body_message += " Tester : " + escape(Tester); body_message += escape("\n"); body_message += " Status : " + escape(Status); body_message += escape("\n"); //alert("body_message:--> " + body_message); var mailto_link = 'mailto:'+email+'?subject='+subject+'&body='+body_message; //alert("mailto_link: " + mailto_link); win = window.open(mailto_link); if (win && win.open &&!win.closed) win.close(); //window.history.back(-1); } Can any body please help me to come out this problem. Regards, Vimal kumar srivastava Madhepura,India hello everyone, I've been trying to build a simple dynamic menu using js and came across the IE getElementById() bug. IE does not accept the elements attributes. Is there another way for going around this? Been struggling with it for weeks now. Any sort of help would be most appreciated. Nivi. Hello I have an adult website and I want an "adult message" to be display when people go to my website, something like this: http://www.latincaramelito.zoomshare.com/ i already tried some codes that i found here but they dont seem to work, the codes a first one: <script> if (!confirm("Do you want to enter this site?")) window.location=history.go(-1) </script> Second one: <html> <head> <script type="text/javascript"> var stay=confirm("The following site contains appalling material suitable only for webmasters. Please 'ok' to enter, 'cancel' to exit immediately!") if (!stay) window.location="http://www.yahoo.com" </script> </head> <body> Appalling material here </body> </html> help me plz, thank you I have an action in PHP where, when a user clicks the delete button i want a confirmation box. How does a confirmation box work with a PHP function. Here is the function. Code: <a href="/order/delete/id/<?php echo $o->id?>"><img src="/gfx/trashicon.gif" /></a> Any help would be appreciated! Ok I know there are a few other posts about this but I can't find one similar to my problem. The confirmation box pops up, but cancel does nothing. it is for deletion of a movie off a server for class, but if you hit cancel it deletes the entry anyway. here is my code: Code: <script type="text/javascript"> function show_confirm() { var r=confirm("Are you sure you want to delete?"); if (r==true) { window.location="movie_delete.cfm?FilmID=#FilmID#"; } } </script> [<a href="movie_delete.cfm?FilmID=#FilmID#" onclick="show_confirm()">Delete</a>] notice anything wrong? Hello, How can this be made to return confirmation? <form id="score_form" method="post" action="addscore.php"><input id="score" name="score" value="" type="hidden"><img id="collect" style="cursorointer;height: 37px; width: 100px; margin-top: 13px;" src="./collectlive.gif" onclick="collect_points();"></form> Letsay the confirmation window would say"ARE YOU SURE" Would greatly appreciate any help with this. Have made a contact form for a website that uses javascript to validate it then once validated prompts the user if the details are correct. Currently its working in chrome and ie but not in firefox. Code is in post #3.
Hi Everyone, Has anyone noticed the twitter confirmation box (when you hit save in Settings, the page refreshes and a white confitmation box appears along the top of the screen and disappears again in a few seconds)? Does anyone know how to go about implementing this? My JS skills would not be the best. I wonder is there a jquery plugin that I could use or similar? Thanks in advance, Brian i hava e java script fr confrmation of record deletion on server side in asp.net function deleteCheck() { if (document.getElementById('H_ctrl').value!="") { alert(document.getElementById('H_ctrl').value) var delconfirm = confirm('Are you sure ? You want to delete ' + document.getElementById('H_ctrl').value +' Details ?') if (delconfirm==true) { var delconfirmAgain = confirm('The Record ' + document.getElementById('H_ctrl').value +' will be deleted permanently. Are you sure? ') if(delconfirmAgain==true) { return true } else { return false } } else { return false } } } BTNDELETE.Attributes("onclick") = "javascript:return deleteCheck();" in the button event i have a query for redord deletion i need to delete the records if u use the return keyword the record doesnot get deleted but if i remove the return keyowrd the record gets deleted even if CANCEL is clicked I have created a button with a window.confirm() method but when I click on it in firefox the dialog box does not appear. It does however appear in all the other browsers
Hi, My code below shows a list of Qualifications and a Delete (Remove) button I would like to show the Qualification name not the setting_id my problem is that I am not passing the Qualification name through in the form... Can someone please help me? JavaScript Code: function confirmqualification() { var SettingID = document.getElementById('setting_id').value; var answer = confirm("Delete entry "+SettingID+" ?") if (answer){ alert("Qualification Deleted") window.location = "delete_qualification.php?&setting_id="+SettingID; } else{ alert("No action taken") } } html Code: <fieldset> <legend>Qualifications </legend> <select name="setting_id" id="setting_id" size="7" style="width:100%;"> <?php while($row1 = mysql_fetch_array($result)) { echo '<option value="'.$row1['setting_id'].'">'.$row1['qualification'].'</option>'; } ?> </select> <input type="button" name="remove" id="remove" value="Remove" onClick="javascript:confirmqualification()" /> </fieldset> Hi all, I want to have a javascript popup box so that when a hyperlink is clicked, a user is asked if they are sure they want to click this link, if they select ok then the page loads, if they click canel then nothing happens, so i have this code below: Code: <script type="text/javascript"> function confirmSubmit() { var agree=confirm("Are you sure you wish to click this link?"); if (agree) return true ; else return false ; } </script> Code: <a onclick="return confirmSubmit()" href="page.html">Page</a> However when a user clicks cancel the link still loads, can anyone see where I am going wrong? any help will be appreciated Hi all.I found this code on a forum to confirm that the user wants to delete the record from database and that the link has not pressed accidently.But it is not deleting the record even after pressing ok.This is may be because the id is not passed properly. Can anyone tell why?Do I need to modify the javascript function?Here is my code: Code: function confirmation() { var answer = confirm("Delete Record?") if (!answer){ window.location = "by_hand.php"; } else { window.location = "delete.php?delete=$id&action=deleteemployee"; } } PHP Code: <a href=# onclick='confirmation()'><img src='images/delete.png' alt='Delete' title='Delete' class='pngfix'></a> Hi Code: var err_str=""; function validate_grid(value,id,ind) { $("#result").html(" ").show(); if(ind==1 || ind==2) { var patt=/^([0][0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; if(!patt.test(value)) { mygrid.setCellTextStyle(id,ind,"background-color:yellow;"); if(err_str!="") err_str+="\n"+(ind+1)+".Enter numbers and : only.."; else err_str=(ind+1)+".Enter numbers and : only"; return false; } else { mygrid.setCellTextStyle(id,ind,"background-color:white;"); return true; } } } alert(err-str); here ind==1 is from_time and ind==2 is to_time,i need to validate time as to_time must be always greater than from-time,if condition fails an alert msg should populate.time format is[05:00]as it is in string format im unable to do the validation for it.(ex:from-time=08:00 to-time=07:59 condition fails) thank you. Hello im using dhtmlx grid in this cells i have from time and to time (i.e ind==1 and ind==2) i need to validate time where to-time must be greater than from-time else it should alert an message,i have writeen a normal Regular expression for the time validation.as the time is i string format i.e[05:00],please can any one send me code for that. Code: var err_str=""; function validate_grid(value,id,ind) { if(ind==1 || ind==2) { var patt=/^([0][0-9]|[1][0-9]|[2][0-3])[:]{1}[0-5][0-9]$/; if(!patt.test(value)) { mygrid.setCellTextStyle(id,ind,"background-color:yellow;"); if(err_str!="") err_str+="\n"+(ind+1)+".Enter numbers and : only.."; else err_str=(ind+1)+".Enter numbers and : only"; return false; } else { mygrid.setCellTextStyle(id,ind,"background-color:white;"); return true; } } } |