momukhtar
Programmer
- Mar 10, 2008
- 8
i have a testpage for a web application in PHP and Javascript.
It has previous, NExt and complete eXam button to browse to different questions and submit exam. When the user would click on Window Close (X), i want a popup (OK, Cancel). If the user click OK then window is closed and php session variable must be destroyed and on CANCEL nothing happens.
To prevent this popup on next, previous and complete exam buttons , i made one hidden field and "onbeforeunload" event is only fired when the window close button is clicked.
I want to know that how can i get the response that the user has clicked on "OK" so that I can destroy the php session variables associated with that test.?
My code is
window.onbeforeunload=confirmExit;
function confirmExit() {
// this conditon to test whether next,previous, completexam button
// or window cloase button has been clicked
if (document.onlinetestform.close.value == "-1") {
return 'If you close your data will be lost and you will forfeit your exam.'
}
}
i just want to know whether user clicked on OK or Cancel in this case
It has previous, NExt and complete eXam button to browse to different questions and submit exam. When the user would click on Window Close (X), i want a popup (OK, Cancel). If the user click OK then window is closed and php session variable must be destroyed and on CANCEL nothing happens.
To prevent this popup on next, previous and complete exam buttons , i made one hidden field and "onbeforeunload" event is only fired when the window close button is clicked.
I want to know that how can i get the response that the user has clicked on "OK" so that I can destroy the php session variables associated with that test.?
My code is
window.onbeforeunload=confirmExit;
function confirmExit() {
// this conditon to test whether next,previous, completexam button
// or window cloase button has been clicked
if (document.onlinetestform.close.value == "-1") {
return 'If you close your data will be lost and you will forfeit your exam.'
}
}
i just want to know whether user clicked on OK or Cancel in this case