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.
} 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" />
Solved this problem with a simple addition to the input button as below:
<input type="submit" value="Move" id="btnMove" name="btnMove" onclick="return confirm('Ensure this report is added to Impact. Do you wish to continue?')" />
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.