SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    911
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Add a 'Are you sure?' alert when user clicks a input button before moving a report to

    I have three input buttons at the bottom of the form, 'Export', 'Move' and 'Un-Check'. Export and Un-Check are fine, but what I need to add to the 'Move' button before the code is activated to move the file is the user gets an alert with a 'Are you sure? question and if clicked yes it continues.

    Code:
    } else if (isset($_GET["btnMove"]))
    {
    	if (is_array($_GET['star'])) {
      $starArray = array();
         foreach($_GET['star'] as $star) {
    	 $starArray[] = '\''.$star.'\'';
         }
    	 $starData = implode(',', $starArray);
    	 $sqlstar =  ' UniqueIdentifier IN ('. $starData .' )';
    	}
    $sql = mysql_query("UPDATE hazzard SET Impact='1' WHERE ".$sqlstar."") or die (mysql_error());
    }
    <input type="submit" value="Move" id="btnMove" name="btnMove" />

  2. #2
    SitePoint Guru
    Join Date
    Feb 2006
    Location
    Chepstow, South Wales
    Posts
    911
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Solved this problem with a simple addition to the input button as below:

    Code:
    <input type="submit" value="Move" id="btnMove" name="btnMove" onclick="return confirm('Ensure this report is added to Impact. Do you wish to continue?')" />
    Thanks

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,863
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by multichild View Post
    Solved this problem with a simple addition to the input button as below:

    Code:
    <input type="submit" value="Move" id="btnMove" name="btnMove" onclick="return confirm('Ensure this report is added to Impact. Do you wish to continue?')" />
    Thanks
    Just remember to replace the JavaScript debugging confirm() call with something else before you make the page live.

    I always check the box in alert, confirm and prompt dialogs to turn off JavaScript as I assume that when those debugging call display that the page owner is asking me to disable JavaScript for their site.

    Here's how alert() and prompt() look in one browser - confirm() looks the same.

    alert.gif prompt.gif
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


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
  •