473,320 Members | 1,920 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,320 software developers and data experts.

How do i get an alert to stop a page from going on

i have this button, i would like this button on click to pop up an alert "are you sure". If yes continue to the url that in the function, if no stay on the page.

Expand|Select|Wrap|Line Numbers
  1.  
  2. <input type="button" id="addlesson" value="Add Lesson!" onClick="inputter(document.getElementById('testid').value)" />
  3.  
  4.  
here is the inputter function

Expand|Select|Wrap|Line Numbers
  1. function inputter(element){
  2.  
  3.             parent.location='studentaddlesson.php?option=&s_id=' + escape(element);
  4.  
  5.         }
  6.  
  7.             $(document).ready(function() {
  8.  
  9.          $('#testid').keyup(function(e) {
  10.  
  11.         if(!e) e = window.event;
  12.  
  13.         if(e.keyCode == 13) {
  14.             inputter(document.getElementById('testid').value);
  15.         }
  16.          }
  17.  
  18.             )
  19.         } )
  20.  
  21.  
So my question is, how do i tie this jquery alert to the button to stop the action. Right now it pops up but does not stop the page from going to the url


Expand|Select|Wrap|Line Numbers
  1. $(document).ready( function() {
  2.  
  3.                 $("#addlesson").click( function() {
  4.                     jConfirm('Can you confirm this?', 'Confirmation Dialog');
  5.  
  6.                 });
  7.                 });
  8.  
  9.  
Nov 6 '09 #1
1 1786
gits
5,390 Expert Mod 4TB
drop the 'hard-assigned' handler from the button and then do something like this in the onload-handler of the page:

Expand|Select|Wrap|Line Numbers
  1. $(document).ready( function() {
  2.     $("#addlesson").click( function() {
  3.         if ( jConfirm('Can you confirm this?', 'Confirmation Dialog') ) {
  4.             inputter(document.getElementById('testid').value)
  5.         }
  6.     });
  7. });
while i assume that the confirm will return a boolean like it should. which JavaScript framework do you use? JQuery? which version?

kind regards
Nov 10 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bill | last post by:
Hi. I have a multi-page form where the user enters datails to be submitted to a database on the final page. To move through the pages I have Next and Previous buttons using the following...
6
by: Jorntk | last post by:
<script language="JavaScript"> !-- function onLoad() { if( self.innerWidth < 1024 ) { self.moveTo( 0, 0 ); self.resizeTo( screen.availWidth, screen.availHeight ); }
9
by: Targa | last post by:
Ive seen alert scripts triggered by links but I need one that will cover any link or pressing the back/forward buttons. Any such thing? TIA
4
by: joe | last post by:
Hi, I defined: <div id="abc"> </div> in my .html file, after an Ajax query my weberserver sends: <script language="JavaScript"> alert('Hello World!"); </script>
13
by: alvin.yk | last post by:
Hi, Normally, a piece of code such as <a href="http://www.yahoo.com" onclick="alert('hello');return false;">link</a> will stop the browser from actually going to href's destination....
1
by: goal2007 | last post by:
I have a user control called InsightIntegMenu.ascx here is the Code Control Language="C#" AutoEventWireup="true" CodeFile="InsightIntegMenu.ascx.cs" Inherits="InsightIntegMenu" %> ...
2
by: Seth Williams | last post by:
In the middle of my event handler (for a button), I have an if/then statement (using vb.net): if (whatever) then strScript="<script ....... strScript &= alert('This is an alert') strscript...
3
by: geevaa | last post by:
Hi All, Using javascript i am displaying an alert... Is there is a way to change the title of the alert box displayed through Javascript Here is my simple javascript code <script type =...
20
by: Peter | last post by:
I need a popup alert after a post back. 1) user clicks on the submit button 2) Server side code runs and if the result is false I want to display a java script alert("It did not work") How to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.