Customizing SMF > SMF Coding Discussion

Created inline javascript "confirmation" popup, but how do I exit calling php?

(1/1)

Shambles:
So here's what I'm trying to achieve:

Members who press the "Mark all messages as read" button (on the screen that summarises all unread messages) should be faced with a popup asking them to OK or CANCEL.

If OK'd, the function MarkRead() should continue.

If CANCEL'd, the function MarkRead() should exit back to the screen containing the list of unread topics.

I've been trying with a bit of inline javascript in file Sources\Subs-Boards.php , just to get to the point where I least get a popup (which I do)


--- Code: ---function MarkRead()
{
global $board, $topic, $user_info, $board_info, $modSettings, $smcFunc;

// No Guests allowed!
is_not_guest();

checkSession('get');

if (isset($_REQUEST['sa']) && $_REQUEST['sa'] == 'all')
{

// mod601 Ask for confirmation that ALL boards are to be marked as read

                         echo '
<script type="text/javascript">
var conf = window.confirm("Are you sure you want to mark all topics as read?")
if (conf)
// allow the "mark as read" to continue
else
        // abandon "mark as read"
</script> ';
...
...

--- End code ---

How do I achieve the "abandon" (conf != 1) effect where Subs-Boards.php exits back to the calling screen? I'm aware that I can't easily get the 'conf' variable back to php due to the obvious server vs client processing stream.

Maybe there's a better way, using "onclick()" on the actual "Mark all messages as read" button, or maybe a php facility to get an interactive message box shown?


Thanks for listening.

Navigation

[0] Message Index

Go to full version