RE: combining PHP with JS

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



[snip]
I have case sentences in PHP and on certain step I want to ask user if
he wants to save the  file.
IF this is true I would do nothing, but if he doesn't want to save it
I want to trigger break; in PHP not to do the next case sentence where
I save the file.
I've tried this, but it wouldn't even trigger confirm and I do not
know where is/are mistake-s?
Please help me. Here is an excerpt:


<?php	

case 'm': #change mode ->that's autosave
$changeMode = $_SESSION['adminType'];
$_SESSION['adminType']=$userType;
?>
<script type="text/javascript">
var answerSave = confirm("Save?");
if (!answerSave){
<?php
break;
?>

}
</script>
<?php	
case 's': #start of save file
[/snip]

You cannot combine server-side and client-side programming like this. PHP would have to flush everything to the screen at the point you're asking it to and then assume that there is 'state' before popping the confirm dialog.

Remember that everything between the server and the client is 'stateless' - they are not aware of each other. You might be able to get close to this functionality using AJAX - but that is still stateless and even more so it is asynchronous (unless you choose to be synchronous and you lock up the browser).

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux