HostGator Reseller Hosting
 
Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read Web Directory

Go Back   Webmaster Forum > Designing and Developing Websites > Programming > Ajax / Javascript

Ajax / Javascript Discussions and help on Ajax and Javascript coding.

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 03-17-2007, 11:06 AM
technoguy technoguy is offline
WMG Citizen
 
Join Date: Mar 2007
Posts: 436
iTrader: (0)
technoguy is on a distinguished road
Default Confirmation dialog

I have a hyperlink which takes me to a delete page when i click over it. What I want to do is , it should display confirmation dialog for yes or no before going to hyperlinked page. If i click yes it should go to that page otherwise it should not go anywhere.

Is it possible?
Reply With Quote
Sponsored Links
Register and sign in to hide this ad block

  #2 (permalink)  
Old 03-20-2007, 05:16 AM
nickvd nickvd is offline
WMG Newcomer
 
Join Date: Mar 2007
Posts: 17
iTrader: (0)
nickvd is on a distinguished road
Default

Take a look at the confirm function.

Code:
if (confirm("Are you sure you want to close this window?")) {
  window.close()
}
Reply With Quote
  #3 (permalink)  
Old 03-20-2007, 08:06 AM
technoguy technoguy is offline
WMG Citizen
 
Join Date: Mar 2007
Posts: 436
iTrader: (0)
technoguy is on a distinguished road
Default

What I want is when someone click yes then it should open another url in same window and if someone click no it should return to same page where it was previously.
Reply With Quote
  #4 (permalink)  
Old 03-20-2007, 08:52 AM
nickvd nickvd is offline
WMG Newcomer
 
Join Date: Mar 2007
Posts: 17
iTrader: (0)
nickvd is on a distinguished road
Default

What I posted will allow you to do what you need... Play around and report back your findings, I'm here to help
Reply With Quote
  #5 (permalink)  
Old 03-20-2007, 10:47 AM
blokey blokey is offline
WMG Resident Alien
 
Join Date: Mar 2007
Posts: 93
iTrader: (0)
blokey is on a distinguished road
Default

Quote:
Originally Posted by technoguy View Post
I have a hyperlink which takes me to a delete page when i click over it. What I want to do is , it should display confirmation dialog for yes or no before going to hyperlinked page.
Does the delete page that you are hyperlinking to actually delete a page with no further confirmation?
Reply With Quote
  #6 (permalink)  
Old 03-20-2007, 11:40 AM
technoguy technoguy is offline
WMG Citizen
 
Join Date: Mar 2007
Posts: 436
iTrader: (0)
technoguy is on a distinguished road
Default

Yes I have a delete page. When I click that hyperlink I am able to delete a record from table using that page. What I want is before going to that page it should ask yes or no.

Hope you understand what I mean.
Reply With Quote
  #7 (permalink)  
Old 03-20-2007, 11:43 AM
blokey blokey is offline
WMG Resident Alien
 
Join Date: Mar 2007
Posts: 93
iTrader: (0)
blokey is on a distinguished road
Default

That's not quite what I meant. When you click this hyperlink, will a record be immediately deleted from the database by the script that runs, and is this why you want a confirmation message?
Reply With Quote
  #8 (permalink)  
Old 03-20-2007, 07:58 PM
nickvd nickvd is offline
WMG Newcomer
 
Join Date: Mar 2007
Posts: 17
iTrader: (0)
nickvd is on a distinguished road
Default

The code I posted will do exactly what you need it to do. I prefer to nudge people into the correct direction, rather than just providing turn by turn directions to their destination. That being said, the following javascript should do what you want:

PHP Code:
var link document.getElementById('id_of_link'); // the delete page link
link.onClick = function(){ // when the link gets clicked
  
if (confirm("Are you sure you wan to continue?")) {
    return 
true//let them continue...
  
}
  return 
false// they canceled out, don't follow the link
}; 
I haven't tested the code, but I cant see anything wrong with it. Test it out, adapt it for your needs and let us know what happens!

note, i used [ php ] tags only for the highlighting, the code is javascript
Reply With Quote
  #9 (permalink)  
Old 04-01-2007, 07:48 AM
technoguy technoguy is offline
WMG Citizen
 
Join Date: Mar 2007
Posts: 436
iTrader: (0)
technoguy is on a distinguished road
Default

I have modified the code and using it now for confimation. Thank you for the code. Is there any solution other than javascript? Because when Javascript is disabled I think it wont work.
Reply With Quote
  #10 (permalink)  
Old 04-01-2007, 10:06 AM
chopstickles chopstickles is offline
WMG Resident Alien

Recent Blog: I hate spam!
 
Join Date: Mar 2007
Location: Makati City, Philippines
Posts: 74
iTrader: (0)
chopstickles is on a distinguished road
Default

If there is no Javascript then it obviously won't work.

I don't there are any other ways with confirmation box popups. Another way of having the confirmation is when you click the delete link you are taken to a new page which comes up with "Are you sure you want to delete such and such", and if you click Yes / No, with Yes deleting the item and no redirecting you back to the previous page.
__________________
Did I help you? Please do the deed and give some reputation.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

All times are GMT. The time now is 09:43 AM.



Freelance Web Designers
Work At Home Forum
Ad Marketplace
Online Deals and Bargains
Ad Marketplace and Auctions Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0