SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question echo & javascript prompts

    PHP Newbie here, but here's my problem:

    I'm trying to add a prompt to my delete story hyperlink, so that I won't accidentaly delete a story.

    The current echo looks like this:
    echo '<a class="editstorylink" href="deletestory.php?id=' .$row['id'] .'">';
    echo '' . delete . '</a>';


    I would like to add the following function inside the hyperlink (currently getting errors when i try to add it):
    onClick="javascript:return confirm('Are you sure?')

    I can't get it to work, any ideas?

  2. #2
    SitePoint Enthusiast thenk83's Avatar
    Join Date
    Sep 2005
    Location
    Hacienda Heights, CA
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Add slashes.... like this:

    onClick="javascript:return confirm(\'Are you sure?\')

    Basically PHP is thinking you're executing 'Are you sure?'. Your echo looks like this:

    echo '<code onclick('are you sure?')>'.$variable.'</code>;

    Tell me if that works for you!
    Mmmmm .NET...PHP...CF...
    AIM: THENK83
    MSN: thenk83@hotmail.com

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by thenk83 View Post
    Add slashes.... like this:

    onClick="javascript:return confirm(\'Are you sure?\')

    Basically PHP is thinking you're executing 'Are you sure?'. Your echo looks like this:

    echo '<code onclick('are you sure?')>'.$variable.'</code>;

    Tell me if that works for you!

    I made the changes which it now looks like this:

    echo '<a class="editstorylink"';
    echo ' onClick="javascript:return confirm(\'Are you sure?\')"';
    echo ' href="deletestory.php?id=' .$row['id'] .'">';
    echo '' . delete . '</span></a><br /><br />';


    And you know what the best part is?........IT WORKS!!!.. You're the MAN!!

  4. #4
    SitePoint Enthusiast thenk83's Avatar
    Join Date
    Sep 2005
    Location
    Hacienda Heights, CA
    Posts
    49
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Awesome! I'm glad I could help ya! Feel free to contact me if you need anything else.
    Mmmmm .NET...PHP...CF...
    AIM: THENK83
    MSN: thenk83@hotmail.com


Bookmarks

Posting Permissions

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