JavaScript - Js Function To Continue To Url After Confirm
I'm working on a bank website that needs disclaimers on their external links. I've searched for a tutorial or a script I could understand but need additional help if anyone is willing..
Here's my page with external links: http://designphilanthropy.org/services/links/ Here's the js I used from the previous bank design (I don't see any code here that will do what I need): Code: <script language="javascript"> <!-- Hide window.resizeTo(440, 440); function go() { var width = screen.width; var height = screen.height; if(width<650) { width = 600; height = 400; } else { width = width - 200; height = height - 100; } window.resizeTo(width, height); location.href=""; } // end Hide --> </script> And here's the code on the "yes" button: Code: <input type="button" VALUE="YES" onclick="javascript:go();"> The link opens the disclaimer and populates the url in the browser, but I don't know how to write the js for it to continue to the destination after clicking "yes" Any help would be greatly appreciated... Similar TutorialsI am having some difficulty in constructing a window.confirm() function that works with my code. So if the form data is valid, I need to use a window.confirm() dialog box to show the user's total cost based on the rental rate of equipment chosen and the reservation period. The user must accept the cost by pressing the confirm button, and if user cancels do not submit data. I have written this code but cannot figure out how to find the number of days from the 2 date fields and use that to calculate and display the total cost. Any help with this will be greatly appreciate. Thanks so much. [This is the part I am having trouble with:] //confirm submit and display rental cost Code: var equip = document.forms[0].equipment.value var pDate = document.forms[0].pickupDate.value var pHours = document.forms[0].pickupHours.value var pMinutes = document.forms[0].pickupMinutes.value var rDate = document.forms[0].returnDate.value var rHours = document.forms[0].returnHours.value var rMinutes = document.forms[0].returnMinutes.value var pTime = pHours + pMinutes var rTime = rHours + rMinutes var total = (((rDate - pDate) - 1) * 24) * equip) + ((rTime + (24 - pTime)) * equip) function confirmSubmit() { var submitForm = window.confirm("'The total rental cost is: ' + total"); if (submitForm == true) return true; return false; } [Below is the code I have so far:] Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <!-- Brooks Rogalski December 6, 2010 --> <title>ABC Outdoor Sports</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <script type = "text/javascript"> /* <![CDATA[ */ //image slideshow function var interval = 4000; // delay between rotating images var random_display = 1; // 0 = no, 1 = yes var pause = false; var image_index = 0; image_list = new Array(); image_list[image_index++] = new imageItem("fishing.jpg"); image_list[image_index++] = new imageItem("biking.jpg"); image_list[image_index++] = new imageItem("climbing.jpg"); image_list[image_index++] = new imageItem("kayaking.jpg"); image_list[image_index++] = new imageItem("scuba.jpg"); var number_of_image = image_list.length; function imageItem(image_location) { this.image_item = new Image(); this.image_item.src = image_location; } function get_ImageItemLocation(imageObj) { return(imageObj.image_item.src) } function generate(x, y) { var range = y - x + 1; return Math.floor(Math.random() * range) + x; } function getNextImage() { if (pause == true) return; if (random_display) { image_index = generate(0, number_of_image-1); } else { image_index = (image_index+1) % number_of_image; } var new_image = get_ImageItemLocation(image_list[image_index]); return(new_image); } function rotateImage(place) { var new_image = getNextImage(); document[place].src = new_image; var recur_call = "rotateImage('"+place+"')"; setTimeout(recur_call, interval); } //validate form functions function validateForm() { var valid = true; //validate equipment if (document.forms[0].equipment.selectedIndex == 0) { window.alert("Please select your equipment type."); document.forms[0].equipment.focus(); return false; } //validate pick-up date if (document.forms[0].pickupDate.value == "'' || '(mm/dd/yyyy)'" ) { window.alert("Please enter your Pick-up Date."); document.forms[0].pickupDate.focus(); valid = false; return valid; } today = new Date(); year = today.getFullYear() ; month = today.getMonth(); day = today.getDate(); //validate pickup date format var re =/^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{2,4}$/ if(document.forms[0].pickupDate.value != '' && !document.forms[0].pickupDate.value.match(re)) { window.alert("Invalid date format: " + document.forms[0].pickupDate.value); document.forms[0].pickupDate.focus(); valid=false; return valid; } var date; var input2=document.forms[0].pickupDate.value; var cyear = parseInt(input2.substring(6,10)); var cmonth = parseInt(input2.substring(0,2)) - 1; var cday = parseInt(input2.substring(3,5)); if ( month < cmonth ){ date = year - cyear - 1; } else if ( month < cmonth ){ date = cyear - year; } else if ( month == cmonth ){ if ( cday < day ){ date = cyear - year - 1; } else if ( day > cday ){ date= cyear - year; } else if ( day == cday ){ date = cyear - year-1; } } if(date < 2){ window.alert('Must be atleast 2 days from today'); valid=false; return valid; } //validate pick-up time hours if (document.forms[0].pickupHours.selectedIndex == 0) { window.alert("Please select the number of hours for pick-up time."); document.forms[0].pickupHours.focus(); return false; } //validate pick-up time minutes if (document.forms[0].pickupMinutes.selectedIndex == 0) { window.alert("Please select the number of minutes for pick-up time."); document.forms[0].pickupMinutes.focus(); return false; } //validate return date if (document.forms[0].returnDate.value == "'' || '(mm/dd/yyyy)'" ) { window.alert("Please enter your Return Date."); document.forms[0].returnDate.focus(); valid = false; return valid; } //validate return date format if(document.forms[0].returnDate.value != '' && !document.forms[0].returnDate.value.match(re)) { window.alert("Invalid date format: " + document.forms[0].returnDate.value); document.forms[0].returnDate.focus(); valid=false; return valid; } if(document.forms[0].returnDate.value <= document.forms[0].pickupDate.value){ window.alert("Please choose later date"); valid=false; return false; } //validate return time hours if (document.forms[0].returnHours.selectedIndex == 0) { window.alert("Please select the number of hours for return time."); document.forms[0].returnHours.focus(); return false; } //validate return time minutes if (document.forms[0].returnMinutes.selectedIndex == 0) { window.alert("Please select the number of minutes for return time."); document.forms[0].returnMinutes.focus(); return false; } //validate first name if (document.forms[0].firstName.value=="") { window.alert("Please enter your first name."); document.forms[0].firstName.focus(); valid = false; return valid; } //validate last name if (document.forms[0].lastName.value=="") { window.alert("Please enter your last name."); document.forms[0].lastName.focus(); valid = false; return valid; } //validate street address if (document.forms[0].street.value=="") { window.alert("Please enter your street address."); document.forms[0].street.focus(); valid = false; return valid; } //validate city if (document.forms[0].city.value=="") { window.alert("Please enter your city."); document.forms[0].city.focus(); valid = false; return valid; } //validate zip code if (document.forms[0].zip.value==""){ window.alert("Please enter your zip code."); document.forms[0].zip.focus(); valid=false; return valid; } var re5digit=/^\d{5}$/ if (document.forms[0].zip.value.search(re5digit)==-1){ window.alert("Please enter a 5 digit number") valid=false; return valid; } //validate date of birth if (document.forms[0].date.value == "'' || '(mm/dd/yyyy)'" ){ window.alert("Please enter your date of birth."); document.forms[0].birthDate.focus(); valid=false; return valid; } var reDateFormat = /^\d{1,2}(\-|\/|\.)\d{1,2}\1\d{4}$/ if(document.forms[0].date.value.search(reDateFormat)==-1){ window.alert("Please enter a standard format. [mm/dd/yyyy]") valid=false; return valid; } //check if over 18 var age; var input = document.forms[0].birthDate.value; var pyear = parseInt(input.substring(6,10)); var pmonth = parseInt(input.substring(0,2)) - 1; var pday = parseInt(input.substring(3,5)); if ( month < pmonth ){ age = year - pyear - 1; } else if ( month > pmonth ){ age = year - pyear; } else if ( month == pmonth ){ if ( day < pday ){ age = year - pyear - 1; } else if ( day > pday ){ age = year - pyear; } else if ( day == pday ){ age = year - pyear; } } if(age < 18){ window.alert('Attention: Under 18!'); valid=false; return valid; } //confirm submit and display rental cost var equip = document.forms[0].equipment.value var pDate = document.forms[0].pickupDate.value var pHours = document.forms[0].pickupHours.value var pMinutes = document.forms[0].pickupMinutes.value var rDate = document.forms[0].returnDate.value var rHours = document.forms[0].returnHours.value var rMinutes = document.forms[0].returnMinutes.value var pTime = pHours + pMinutes var rTime = rHours + rMinutes var total = (((rDate - pDate) - 1) * 24) * equip) + ((rTime + (24 - pTime)) * equip) function confirmSubmit() { var submitForm = window.confirm("'The total rental cost is: ' + total"); if (submitForm == true) return true; return false; } } /* ]]> */ </script> </head> <body onload = "rotateImage('rImage')"> <h1> ABC Outdoor Sports Equipment </h1> <img src="fishing.jpg" id="rImage" width="250" height="200" onmouseover = "pause=true;" onmouseout = "pause=false;"> <br/> <br/> <form onsubmit = "return validateForm();" action = "mailto:rogalskibf@gmail.com?subject=ABC Customer Reservation" method="post" enctype="text/plain"> <table border = "0"> <tr> <td> Equipment:<br/> <select name = "equipment"> <option value="unselected">Select Equipment Type</option> <option value = 20>Fishing Boat</option> <option value = 15>Kayak</option> <option value = 2>Mountain Bike</option> <option value = 10>Scuba Gear</option> </select> </td> </tr> <tr> <td> Pick-up Date: <br/> <input type = "text" name = "pickupDate" value = "(mm/dd/yyyy)"/> </td> <td> Pick-up Time: <br/> <select name = "pickupHours"> <option value="unselected">hr</option> <option value = 7>07</option> <option value = 8>08</option> <option value = 9>09</option> <option value = 10>10</option> <option value = 11>11</option> <option value = 12>12</option> <option value = 13>13</option> <option value = 14>14</option> <option value = 15>15</option> <option value = 16>16</option> <option value = 17>17</option> </select> <select name = "pickupMinutes"> <option value="unselected">min</option> <option value = 0>00</option> <option value = .5>30</option> </select> </td> </tr> <tr> <td> Return Date: <br/> <input type = "text" name = "returnDate" value = "(mm/dd/yyyy)"/> </td> <td> Return Time: <br/> <select name = "returnHours"> <option value="unselected">hr</option> <option value = 7>07</option> <option value = 8>08</option> <option value = 9>09</option> <option value = 10>10</option> <option value = 11>11</option> <option value = 12>12</option> <option value = 13>13</option> <option value = 14>14</option> <option value = 15>15</option> <option value = 16>16</option> <option value = 17>17</option> </select> <select name = "returnMinutes"> <option value="unselected">min</option> <option value = 0>00</option> <option value = .5>30</option> </select> </td> </tr> <tr> <td> First Name: <br/> <input type = "text" name = "firstName"/> </td> <td> Last Name: <br/> <input type = "text" name = "lastName"/> </td> </tr> <tr> <td> Street: <br/> <input type = "text" name = "street"/> </td> <td> City: <br/> <input type = "text" name = "city"/> </td> <td> Zip:<br/> <input type = "text" name = "zip" maxlength = "5"/> </td> </tr> <tr> <td> Date of Birth: <br/> <input type = "text" name = "date" value = "(mm/dd/yyyy)"/> </td> </tr> <tr> <td colspan = "3" align = "center"> <input type = "submit" name = "submit" value = "Submit Reservation"/> </td> </tr> </table> </form> </body> </html> Hi There, Below is some very basic html/javascript that asks for a user to enter a number in an input text box and then a button is pressed it writes out a line that number of times. It works, but when run in firefox the pages always seems to continue to load... that is, the cursor is continuously that when a page is loading (an arrow with a little circle) and the status bar in the bottom right hand corner seems to be always be at zero. It seems to be something in the for loop as when this is take out it works. Seems to work in IE however? Any ideas? Is this a FireFox thing or am I not terminating the loop properly? Code: <html> <head> <script type="text/javascript" language="javascript"> <!-- function writeloop(){ var noTimes = document.theForm.theAmount.value; for(x=0;x<=noTimes;x++){ document.write("A line!"+"<br />"); } } function cleantext(){ document.theForm.theAmount.value=""; } //--> </script> <title>Write Loop</title> </head> <body> <form name="theForm" action="#"> <input type=button value="Press me" onclick="writeloop();" /> <br /><br /> Enter the amount of times:  <input type=text name="theAmount" value="blah" onfocus="cleantext()"/> </form> </body> Many thanks! I amcalling a JS confirm function from my code behind like this: If bResetNewUser Then strMessage = "Your profile was successfully updated. Would you like to be redirected to the Inquiry screen?" ClientScript.RegisterStartupScript(Me.GetType(), "confSQUpdateScript", "ConfirmSQUpdate('" & strMessage & "');", True) My JS function is as follows: function ConfirmSQUpdate(message) { if (confirm(message)) { window.location = "ClaimantInquiry.aspx" }else { window.location = "http://www.labor.vermont.gov/" } } When I click the Update Profile button the first code snippet executes except no confirm message box appears and hence no redirect. The page says there is an error and the error is Object expected on the ClientScript... line. I have this same functionality with alert boxes and they all work. What gives? Hello, this is not and advert This is a class i built in javascript What it dose: When users leave a site that has a confirm you want to leave box from the browser Why have i posted: I have seen around on the internet posts about how to do such a thing so i though i would get hits to codding forum when user search for such a thing and any one of codding forum members could help it get better Well this is a nice little object to use insted that dose a light box effect and brings up a Yes/no true/false box you set what you want it to say The JSON Object PHP Code: confirmBox = { 'message' : 'This is a Confirm Box', 'trueTxt' : 'True', 'complete' : true, 're' : '', 'falseTxt' : 'False', 'onTrue' : 'alert("true")', 'onFalse' : 'alert("false")', 'setTrue' : function(ontrue){ this.onTrue = ontrue + "confirmBox.update('true')"; }, 'setFalse' : function(onfalse){ this.onFalse = onfalse + "confirmBox.update('false')"; }, 'setTrueText' : function(trueText){ this.trueTxt = trueText; }, 'setFalseText' : function(falseText){ this.falseTxt = falseText; }, 'setText' : function(text){ this.message = text; }, 'hide' : function(){ var bg = document.getElementById('___confirmBox_bg'); var center = document.getElementById('___confirmBox_center'); var dialog = document.getElementById('___confirmBox_dilog'); center.removeChild(dialog); bg.removeChild(center); document.body.removeChild(bg); }, 'show' : function(){ this.createBG(); this.createCenter(); this.createDialog(); }, 'update' : function(sw){ this.re = sw; }, 'state':function(){ if(this.re = ''){ return false; }else{ return this.re; } }, 'createBG' : function(){ var bg = document.createElement("div"); bg.setAttribute('style', "display: table; position: absolute; top: 0%; left: 0%; width: 100%; height: 100%; background-color: black; z-index:1001; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80);"); bg.setAttribute('id', '___confirmBox_bg'); document.body.appendChild(bg); }, 'createCenter' : function(){ var center = document.createElement('div'); center.setAttribute('style',"#position: absolute; #top: 50%; display: table-cell; vertical-align: middle; margin-left:auto; margin-right:auto;"); center.setAttribute('id', '___confirmBox_center'); document.getElementById('___confirmBox_bg').appendChild(center); }, 'createDialog' : function(){ var dialog = document.createElement('div'); dialog.setAttribute('style', "display:block; width: 300px; padding: 16px; background-color: white; z-index:1003; margin-left:auto; margin-right:auto;"); dialog.setAttribute('id', '___confirmBox_dilog'); dialog.innerHTML = this.message + '<div align="right"><input type="button" onclick="eval(confirmBox.onTrue); confirmBox.hide();" value="' +this.trueTxt + '" /><input type="button" onclick="eval(confirmBox.onFalse); confirmBox.hide();" value="' + this.falseTxt + '" /></div>'; document.getElementById('___confirmBox_center').appendChild(dialog); }, } Then this is how you call it and set propertys Code: <script src="confirmBox.js" type="text/javascript"></script> <script type="text/javascript"> confirmBox.setText("This is a test"); //Sets the text to show in the box confirmBox.setTrueText("I can see it"); // sets the text on the return true button confirmBox.setFalseText("I can't see it"); // sets the text on the return false button confirmBox.setTrue('alert("Thanks");'); //what to do when true is clicked confirmBox.setFalse('alert("Your a lier");');// what to do when false is clicked confirmBox.show(); // Show the confirmBox </script> Ok, I need some help with this. When you click the close button on your browser, I want it to have a confirmation. Saying "**Click OK to be redirected to a new page**" something like that. If you click "OK" you are redirected to another page. If you hit CANCEL, then it closes out. It doesn't have to be a confirmation. Just needs to be something that has an option. (Maybe return xx?) Anyways, here's what I've got: Code: <script type="text/javascript" language="javascript"> var sure = false; var lin = false; function sureF() { if(!sure && !lin) { sure = true; var con = confirm("**Are you sure you want to leave?**") if(con == true) { location.href = "http://www.google.com/" return con; } else { alert("Sorry") } } } window.onbeforeunload = sureF; </script> What that does, is when you click close on your browser, it will say "Are you sure you want to leave?" you click "OK", and you get redirected to google .com (How I set it) BUT then a popup comes up saying, "Are you sure you want to navigate away?" which I don't want at all. As you can see, my script is quite messed up. Could you help me out? Thanks. Hi, when my page loads it starts with a confrim box. If "Cancel" is selected then the rest of the page loads fine. If "Ok" is selected nothing after the confirm box loads. Any ideas. Also, it appears that IE and Firefox have trouble with this type of media and Chrome will only play the audio file for about 15 seconds. Any solutions? Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Justin Revard</title> <style type="text/css"> html, body {height: 100%; margin: 0; padding: 0;} #background {position:fixed; top:0; left:0; width:100%; height:100%;} #content {position:relative; z-index:1;} </style> </head> <body> <p><img id="background" src="Images/siteBackground.jpg" /></p> <div id="content"> <h1>Justin Revard's Home Page</h1> <p> <script type="text/javascript"><!-- var r = confirm("Would you like a background tune?"); if (r == true) { document.body.innerHTML += '<object class="plugin_video" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="480" width="640"><param name="autoplay" value="true" /><embed title="QuickTime" hidden="true" src="sounds/siteBG.wav" mce_src="sounds/siteBG.wav autoplay="true" loop="true" controller="true"></embed></object>'; } else { alert("If you change your mind reload the page to choose again."); } // --></script> </p> <p> <table> <tbody> <tr> <td><a href="Source/page2.html" style="opacity:0">Page 2</a></td> <td><a href="Source/page3.html" style="opacity:0">Page 3</a><br /></td> <td><a href="Source/today.php" style="opacity:0">Today's Date</a></td> <td><a href="Source/morePHP.php" style="opacity:0">More PHP</a></td> <td><a href="Source/database.php" style="opacity:0">Database</a></td> <td><a href="source/products.html" style="opacity:0">Products</a></td> <td><a href="Source/origFileRead.php" style="opacity:0">Original File Reader</a></td> <td><a href="Source/fileRead.php" style="opacity:0">File Reader</a></td> </tr> <tr> <td><a href="http://justinrevard.com"><img src="Images/homeButton.jpg" /></a></td> <td><a href="foosball.html"><img src="Images/foosballButton.jpg" /></a></td> <td><a href="physics.html"><img src="Images/physicsButton.jpg" /></a></td> <td><a href="skiing.html"><img src="Images/skiingButton.jpg" /></a></td> <td><a href="message.html"><img src="Images/messageButton.jpg" /></a></td> <td><a href="links.html"><img src="Images/linksButton.jpg" /></a></td> <td><a href="aboutMe.html"><img src="Images/aboutMeButton.jpg" /></a></td> </tr> </tbody> </table> </p> </div> <p> </p> </body> </html> Hi, I am trying to give the user the option of music on my homepage (b/c we've all found it annoying at times...perhaps most times). I have found an "onload" option for the body tag on dotnetspider.com, but it doesn't seem to be working for me. Please take a look and let me know of any improvements I could make. Thx Code: <body onload="loadMusic()"> <p> <script type="text/javascript"><!-- function loadMusic() { var r=confirm("Would you like a background tune?"); if (r==true) { <input type="button" onclick="show_confirm()" value="Show a confirm box" /> <object class="plugin_video" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="480" width="640"> <param name="autoplay" value="false" /><embed title="QuickTime" hidden="true" src="sounds/siteBG.wav" mce_src="sounds/siteBG.wav" autoplay="true" loop="true" controller="true"></embed> </object> } else { alert("If you change your mind reload the page to choose again."); // --></script> I have an user table like this:- guid | username | password | firstname | lastname | location | emailad dress | userrole -----------------------------------+----------+----------------------------------+-----------+-----------+----------+-------- ------+--------------- 8024259764dc3e8ee0fb6f5.84107784 | james | 827ccb0eea8a706c4c34a16891f84e7b | james | bond | NY | ny@live .com | administrator 18689183644dc3e91571a364.71859328 | saty | 250cf8b51c773f3f8dc8b4be867a9a02 | saty | john | NY | hk@fd.c om | administrator 2644885344cecd6f2973b35.63257615 | admin | 21232f297a57a5a743894a0e4a801fc3 | System | Generated | | | administrator (3 rows) now my postgre query for delete the row .... $query = "delete from users where username!= 'admin' and guid='".$guid."'"; $result = pg_query($conn, $query); ?> <script type="text/javascript"> alert("Cannot delete this .\n It is system generated(s)."); </script> <?php (1)when I delete the user name one by one then delete occurs in my page userlist.php, I donot want to delete admin so i use username!= 'admin' in where condition as shown above. (2)now when I del any username(3 rows) from user table then alert occurs & it delete from userlist.php after that my page userlist.php is blank. Finaly when i refresh the page then my admin username seen.. when i use return true; function then only alert generate .. delete doesnot occurs ... Actauly i want:- (1)if user is not admin then it delete from userlist.php ... nd also i m continue on this page ... like when james and saty want to delte their acount ..as given in table. (2)if user is admin then alert generate nd i m continue on this page. i m tired now plz help me .... so can anyone put the best condition in my coding. I've been trying to write a script that activates a confirm box when a browser window is closed. I want this to occur only when they try to close the window, not if they click on links on the page to navigate elsewhere. The confirm box then gives the option to continue closing as they intended or, if they click on ok (or cancel if it's easier), navigate to another page I specify. The script below works but it displays a confirm box when you close the window and click on links. Code: <script type="text/javascript"> function show_confirm() { var r=confirm("Wait! Would you like check out yahoo?"); if (r==true) { window.open("http://www.yahoo.com"); } else { window.close(); } } window.onbeforeunload = show_confirm; </script> I understand you may be able to create a variable that you then attach to any links on the page you don't want to activate the confirm box. I don't know how to do this. Thank you. Hi, im using this code as a fancybox replacement for confirm. Code: function fancyAlert(msg) { jQuery.fancybox({ 'modal' : true, 'content' : "<div style=\"margin:1px;width:240px;\">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><input style=\"margin:3px;padding:0px;\" type=\"button\" onclick=\"jQuery.fancybox.close();\" value=\"Ok\"></div></div>" }); } function fancyConfirm(msg,callback) { var ret; jQuery.fancybox({ modal : true, content : "<div style=\"margin:1px;width:240px;\">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><input id=\"fancyConfirm_cancel\" style=\"margin:3px;padding:0px;\" type=\"button\" value=\"Cancel\"><input id=\"fancyConfirm_ok\" style=\"margin:3px;padding:0px;\" type=\"button\" value=\"Ok\"></div></div>", onComplete : function() { jQuery("#fancyConfirm_cancel").click(function() { ret = false; jQuery.fancybox.close(); }) jQuery("#fancyConfirm_ok").click(function() { ret = true; jQuery.fancybox.close(); }) }, onClosed : function() { callback.call(this,ret); } }); } function fancyConfirm_text() { fancyConfirm("Ceci est un test", function(ret) { alert(ret) }) } how can i use fancyConfirm via an onclick in a hyperlink? thanks for your help! Hello, I'm new to Javascript, but have been programming in PHP and other web codes for 4 years now. I was wondering how you would check if a checkbox was ticked, upon its selection and then unhide HTML content, and then hide such content when deselected.. So far I have this: Code: <script type="text/javascript"> function Agree() { document.getElementById("stepTwo").className = ""; } </script> Which is called by onclick="Agree()" on the select box itself.. I understand an if statement is needed, but how would one go about doing this as my if statements do not appear to be working. Hi I really really really need your help since I have no idea about this. How can I insert the Javascript Confirmation Alert into the del.php file? I have this del.php file PHP Code: <?php require ("include/config.php"); $id=$_REQUEST['id']; $strSQL = "DELETE FROM change WHERE id = '".$id."' "; $objQuery = odbc_exec($conn,$strSQL); if($objQuery) { echo "<script language='Javascript'>alert('Deleted.'); window.location=\""."index.php?action=syif\"</script>"; } else { echo "Error Delete [".$strSQL."]"; } odbc_close($conn); ?> This is the confirmation javascript Code: <html> <head> <script type="text/javascript"> function show_confirm() { var r=confirm("Delete?"); if (r==true) { alert("Deleted!"); } else { alert("Cancelled!"); } } </script> </head> <body> <input type="button" onclick="show_confirm()" value="Show confirm box" /> </body> </html> Hi Guys, I would like to add a confirmation to this: PHP Code: echo "<a href=\"delete.php?dir=$dir&file=$file\" onclick='return del(this, \"$id\")'><img src=\"images/delete.gif\" border=\"0\" /></a>"; However I seem to be struggling, severely! Any help would be greatly appreciated, especially if spelt out if alphabetti spaghetti. Kind Regards, Drew how can you do onclick="return getconfirm('do you want to logout?');" onClick="window.location('logout.asp');" on the same button , if confirm then go url else stay here ? thank you I have the following code written to give a user the option of participating in our survey, however, I cannot get it to only pop up when leaving the domain vs. clicking links internally. I have searched and searched and tried to implement code that I found on here among other sites without luck. I know I am just screwing up something simple so I need your help! I have also tried to implement code to set and read cookies so that it doesn't pop up excessively for a user. Although I would be ok without the cookie code. Here is what I got: 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>Untitled Document</title> </head> <body> <script> window.onbeforeunload = function(){ location.assign('http://www.survey.com'); return "Thanks for visiting! We would appreciate if you could take the time to fill out our short survey to enhance your experience with our organization. To take our survey please hit CANCEL below. To continue without taking our survey just hit OK. Thanks again!"; } </script> </body> </html> Thanks in advance for your help. I didn't include any other code that I tried to implement as I figured it would be easier for you all to direct me in the right direction and help implement the code into mine. http://tinyurl.com/bw2y3sr This is my site and I want to create a Yes and No dialogue box when user closes a browser so this popup confirm dialogue should appear. Can anyone help me? I feel stupid for asking a question about searching arrays, when there's a very similar thread that has been answered just recently on the first page; however, I'm still having trouble contemplating my own scenario. Basically, my program prompts the user for the length of the array and then asks the user to fill the array with words. Here is where I need help: I want to confirm if the user wants to search the array for those words. If so, the user will then be prompted to enter the word he wishes to search for; if found, the location of that word will be reported and the number of times the word has been searched for will be kept track of in a separate array. Here is what I have so far: Code: /* -- phase 3 ------------------------------------------------------ search for words the user asks for */ // search variables var response; var search; while (true) { // confirmation protocol response = confirm("Do you wish to search the lexicon for a word?") if (response) { search = prompt("What word would you like to search for?"); // alert("search"); } else { alert("Thank you for wasting my time."); break; } // begin search protocol for (i=0; i<words.length; i++) { if (search==words[i]) { alert("Word found at" +i+);} } // end for loop else {alert("word not found.");} // counter array/accumulator var hits = new Array(words.length); hits[i] = 0; for (i=0; i<words.length; i++) { if (words[i] == search) { hits[i] = hits[i] + 1; alert("This word has been searched for " +hits[i]+ "times."); } } // end for loop } // end while The problem with my search seems to be that the search is parsed through the for loop; if it finds the word it alerts me that it was found at i location, but then it continues through and sees that the search does not equal the other values in the array and reports it's not found as well. My counter array is completely off, and I'm really at a loss to figure it out. I can see that the problem might be that each new search resets the hits[i] to equal 0, so no matter how many times a word is searched for, it returns a count of 1. I really want this array to track the number of hits for each word searched for, but have no clue why it's not working. Thanks for any help I can get; and please, feel free to critique my coding style, I definitely need to improve. ok so all I want to do is allow a user to confirm that they've clicked the deactivate button...if they click 'ok' deactivate the affiliate...else just return to the list what is happening is I click on deactivate and the confirmation pops up (so far so good); if I click ok then it deactivates the affiliate the way it's supposed to - but if I click cancel it still deactivates the affiliate instead of returning to the list Code: <script type="text/javascript"> function confirmation() { if (confirm("Are you sure you want to deactivate this affiliate? Doing so will deactivate all of its users as well.")){ window.location = "affiliates.php?deactivate='.$_GET['deactivate'].'"; } else { window.location = "affiliates.php"; } } </script> any help is greatly appreciated! I am not sure why this is happening, but the script is working and throwing an alert but still submits. Code: <script type="text/javascript"> function check(a,b) { var obja = document.getElementById('email') var objb = document.getElementById('confemail') if (obja.value==objb.value) {} else {alert("The e-mail fields aren't the same!!") } return false; } </script> Code: <table> <tr><td colspan="2">Email:</td></tr> <tr><td colspan="2"> <input type="text" name="email" class="wide" id="email"></td></tr> <tr><td colspan="2">Confirm Email:</td></tr> <tr><td colspan="2"> <input type="text" name="confemail" id="confemail" class="wide"></td></tr> <tr><td colspan="2"><br /> <input name="Submit" type="submit" value="Submit Help Request" onclick="check('email','confemail') "></td></tr> </table> does anyone see the issue? Thanks for any help. hi all, ok, i have been asked to alter our project management system (one i wrote) to alert users to the fact that they are closing windows with unsaved work in - some of them forget they have edited a page and just close the window. 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>Untitled Document</title> <script type="text/javascript"> var docChanged = false; function docChange(){ docChanged = true; } function checkForChanges() { if(docChanged == true) { return "All changes made to this page will be lost!"; } } window.onbeforeunload = checkForChanges; </script> </head> <body> <form id="form1" name="form1" method="post" action=""> <label> <input type="text" name="one" id="one" onchange="docChange()" /> </label> <label> <input type="text" name="two" id="two" onchange="docChange()" /> </label> <br /> <a href='http://www.google.com'>Google</a> </form> </body> </html> the above will prompt the user if they want to save if fields etc have been changed. is there a way i can dynimcally add the onchange="docChange()" to all fields on a page? the system has hundreds of fields and doing a mass search and replace might be very dangerous lol. im pretty sure it can be done but wouldnt know where to start. ive never really had enough time to learn all the window.addEventListener stuff. |