Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how to use if(confirm)

    I know nothing about Java, but was looking for a popup box confirmation and found this but not sure how syntax should go. Just wanted to add a popup (yes/no) box prior to actualy deleteing a record, the page menu_delete.php just has code to delete record.

    this is my current link to delete page/function
    Code:
    <a href="menu_delete.php?recordID=<?php echo $row_rsMenu['ID']; ?>">Delete</a>
    new code not sure what to put in "what should I add here" section to redirect to menu_delete.php with recordID.
    Code:
    <a href="javascript:if(confirm('Are you sure you want to permanently delete &quot;Menu Item&quot;?')){  what should I add here  }">Delete</a>&nbsp;
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You might try: onclick="if(!confirm(...)) return false;", on the php link...
    Last edited by codegoboom; 01-13-2005 at 05:49 PM.
    *this message will self destruct in n-seconds*

  • #3
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    This will teach you about confirm

    http://www.pageresource.com/jscript/jconfirm.htm

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #4
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    codegoboom, A1ien51

    Thanks to you both ended up using both methodes on my page


    Code:
    <a href="javascript:if(confirm('Are u sure you want to delete this record;?')){document,location.href='menu_delete.php?recordID=<?php echo $row_rsMenu['ID']; ?>';}">Delete</a>&nbsp;
    Code:
    <input type=button onclick="if(confirm('Are you sure you want to add a new record')) document,location.href='menu_add.php';" value="Add a New Record">
    I have learned way to much this week my brain hurts.....
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by musher
    Code:
    <a href="javascript:if(confirm('Are u sure you want to delete this record;?')){document,location.href='menu_delete.php?recordID=<?php echo $row_rsMenu['ID']; ?>';}">Delete</a>&nbsp;
    This is more accessible than the above code:

    <a href="menu_delete.php?recordID=<?php echo $row_rsMenu['ID']; ?>" onclick="return confirm('Are u sure you want to delete this record?')">Delete</a>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    Regular Coder musher's Avatar
    Join Date
    Jan 2005
    Location
    Minnesota
    Posts
    203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hey thanks glenngv
    and that actualy makes more sense to me then the javascript one.
    Thanks
    Jim M

    "Lord, help me to become the person my dog thinks I am" - Dawn Ewing
    "If you must know. Yes, I do enjoy running after the dog sled when I fall off" - Me

    www.huskyzone.com -- Woodland Siberians


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •