By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,394 Members | 1,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,394 IT Pros & Developers. It's quick & easy.

Are you sure?-standardized function?

P: n/a
Hi,

I want to make a standard-function that handles "Are you sure"-type
questions.

In my idea it should look something like this:

<code>
Function deleteitem($item)
{

if (checkback("Are you sure you want to delete this item?"))
{
# delete SQL function code
}

}
</code>

where the code of the function checkback will ask a simple yes/no question.
As far as I found out, this is difficult since you need two steps to get an
answer from a html page. If there any standard way how to do this?

thanks

Oliver

Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Oliver Spiesshofer wrote:
Hi,

I want to make a standard-function that handles "Are you sure"-type
questions.

In my idea it should look something like this:

<code>
Function deleteitem($item)
{

if (checkback("Are you sure you want to delete this item?"))
{
# delete SQL function code
}

}
</code>

where the code of the function checkback will ask a simple yes/no
question. As far as I found out, this is difficult since you need two
steps to get an answer from a html page. If there any standard way how to
do this?

thanks

Oliver


Hi Oliver,

I alway handle that type of 'are you sure' in Javascript.
Just create a button instead of a submit in the form and call confirm:

<input type="button" value="delete" onClick="checkDelete()">

function checkDelete(){
if (confirm("are you sure?")) {
document.forms["formnamehere"].submit();
}
}
If you want PHP to ask the question, you are stuck with an extra
intermediate page, because PHP can only communicate with a client by giving
HTML with the question in it.

About 'standard way': Is there a standard way to walk?
It is just so basic that I don't think it is worth creating a framework for.

Try something like this as intermediate page:

Are you sure?
<br>
<a href="thispage.php?suredelete=Y">Yes</a>
<br>
<a href="thispage.php?suredelete=N">No</a>

<?
if (isset($_GET["dodelete"])) {
if ($_GET["dodelete"] == "Y") {
// deletesql here.
}
}
?>


Hope that help.

Regards,
Erwin Moller
Jul 17 '05 #2

P: n/a
typocorrection:
Are you sure?
<br>
<a href="thispage.php?suredelete=Y">Yes</a>
<br>
<a href="thispage.php?suredelete=N">No</a>

<?
if (isset($_GET["dodelete"])) {
if ($_GET["dodelete"] == "Y") {
// deletesql here.
}
}
?>


they should all be suredelete or dodelete of course. :-)

Jul 17 '05 #3

P: n/a
There's really not standard way to do this. It depends on how you want to
display the message. A really simple implementation would redirect the
request to a confirmation page, which send the POST/GET back to the page of
origin. Or you can create a function that prints out a form, stuffing
variables in $_POST into hidden fields and those in $_GET into the Action
attribute, which posts back to the same page.

Uzytkownik "Oliver Spiesshofer" <ol****@email.com> napisal w wiadomosci
news:Xn***************************@63.223.5.254...
Hi,

I want to make a standard-function that handles "Are you sure"-type
questions.

In my idea it should look something like this:

<code>
Function deleteitem($item)
{

if (checkback("Are you sure you want to delete this item?"))
{
# delete SQL function code
}

}
</code>

where the code of the function checkback will ask a simple yes/no question. As far as I found out, this is difficult since you need two steps to get an answer from a html page. If there any standard way how to do this?

thanks

Oliver

Jul 17 '05 #4

P: n/a
On Wed, 03 Mar 2004 12:19:06 +0100, Erwin Moller
<si******************************************@spam yourself.com> wrote:
Oliver Spiesshofer wrote:
I want to make a standard-function that handles "Are you sure"-type
questions.
I alway handle that type of 'are you sure' in Javascript.
Just create a button instead of a submit in the form and call confirm:

<input type="button" value="delete" onClick="checkDelete()">

function checkDelete(){
if (confirm("are you sure?")) {
document.forms["formnamehere"].submit();


That's very unfriendly to readers without Javascript though. They go
through the process of entering whatever data is involved and then when
they click on the submit button, nothing happens.

Far better is to first get the process working via PHP. If the process
can then be made more responsive for those readers who have Javascript
available, then fine.

--
Stephen Poley

http://www.xs4all.nl/~sbpoley/webmatters/
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.