Click to See Complete Forum and Search --> : MessageBox using a php function
nst
July 26th, 2005, 02:12 PM
Hello,
is there any php function to create a MessageBox like the following javascript function does?
if(confirm('Are you sure you want to delete tihs record?')) {
document.write('OK');
}
else {
document.write('NOOO!');
}
Of course I want that the value of the click will be returned into a php $variable.
Thanks in advance.
PeejAvery
July 26th, 2005, 06:53 PM
if(confirm('Are you sure you want to delete tihs record?')) {
document.write("<?php $variable = 'OK' ?>");
}
else {
document.write("<?php $variable = 'NOOO!!!' ?>");
}
nst
July 27th, 2005, 02:08 AM
mmmm, it's not so simple.
file confirmation_1.php
<html>
<head>
</head>
<body>
<p> </p>
<p><a href="confirmation_2.php">confirmation_2.php</a></p>
</body>
</html>
file confirmation_2.php
<html>
<head>
</head>
<body>
<script language="javascript">
if(confirm('Are you sure you want to delete tihs record?')) {
document.write("<?php $variable = 'OK' ?>");
}
else {
document.write("<?php $variable = 'NOOO!!!' ?>");
}
</script>
<?php
echo "$variable";
?>
</body>
</html>
Whichever you click you get always as result in $variable the second value
$variable='NOOO!!!'
olivthill
July 27th, 2005, 03:53 AM
Here is a solution that I have already used several times. It is almost the same as the one presented by peejavery.
I have a button
print("<input type=button name=B_supp_conf value=\"Delete\" "
." onClick=\"action_supp('".rawurlencode($record_number)."')\">");
And I have a little form
$form_supp = <<<eod_supp
<script language="JavaScript">
<form name=f_supp action=$HTTP_SERVER_VARS['PHP_SELF'] method=post>
<input type=hidden name=H_record_number value="">
<input type=hidden name=H_supp value="S">
</form>
<script language="JavaScript">
function action_supp(record_number) {
document.f_supp.H_record_number=record_number;
if (confirm('Are you sure you want to delete this record? '))
f_supp.submit();
return true;
}
</script>
eod_supp;
print($form_supp);
Then I have that piece of code to delete the record
if (isset($_POST['H_supp'])) {
$record_number = $_POST['H_record_number'];
...
}
Maybe you don't need to pass the record number.
I put these three pieces of code in the same php file.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.