|
-
July 26th, 2005, 02:12 PM
#1
MessageBox using a php function
Hello,
is there any php function to create a MessageBox like the following javascript function does?
Code:
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.
Last edited by nst; July 26th, 2005 at 03:50 PM.
-
July 26th, 2005, 06:53 PM
#2
Re: MessageBox using a php function
Code:
if(confirm('Are you sure you want to delete tihs record?')) {
document.write("<?php $variable = 'OK' ?>");
}
else {
document.write("<?php $variable = 'NOOO!!!' ?>");
}
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
July 27th, 2005, 02:08 AM
#3
Re: MessageBox using a php function
mmmm, it's not so simple.
file confirmation_1.php
Code:
<html>
<head>
</head>
<body>
<p> </p>
<p><a href="confirmation_2.php">confirmation_2.php</a></p>
</body>
</html>
file confirmation_2.php
Code:
<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!!!'
Last edited by nst; July 27th, 2005 at 02:48 AM.
-
July 27th, 2005, 03:53 AM
#4
Re: MessageBox using a php function
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
Code:
print("<input type=button name=B_supp_conf value=\"Delete\" "
." onClick=\"action_supp('".rawurlencode($record_number)."')\">");
And I have a little form
Code:
$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
Code:
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|