472,985 Members | 2,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,985 software developers and data experts.

Are you sure?-standardized function?

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
4 4968
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: BKM | last post by:
I've been using the following 2 ways to make sure my WebBrowser is finished loading a page before continuing with the next code. do:doevents:loop while WebBrowser.Busy do:doevents:loop until...
1
by: Jeff Uchtman | last post by:
Query in ASP against a MS SQL DB. <% Dim Sql Dim Conn Dim totalCount Dim rsCount Dim rsACount Dim PetACount Dim rsBCount
1
by: Sean Berry | last post by:
I saw some sample code of whay I think was wither js or html... can't remember. But, it would create the effect of a yellow popup window that appeared when you left you mouse button over a link. ...
1
by: Susan Addams | last post by:
I know there's a way to do this -- I've seen it before but can't remember how it was done. When using CSS positioning, how do you make sure the copyright notice ends up at the bottom of the...
7
by: simondex | last post by:
Hi, Everyone! How could I make sure that nine values (from 0 to N) are all different without writing too many loops? I am not afraid of statistical parameters (e.g. coefficient of variation,...
7
by: Nathan Sokalski | last post by:
I have a form that allows the user to upload a file. Even though <input type="file" runat="server"> is intended to have the user choose the file using the browse button, it still allows them to...
37
by: yogpjosh | last post by:
Hello All, I was asked a question in an interview.. Its related to dynamically allocated and deallocated memory. eg. //start char * p = new char; ...
6
by: Alex Maghen | last post by:
Let's say I have a web forms button which performs a Delete or something. I'd like a click on the button to pop an "Are you Sure" dialog on the client side and then only execute the button's...
2
by: Henry | last post by:
I am trying to work my way through a textbook on web services. I was running a help page and got this error message. To me it is vague. Not knowing the code well enough I am not sure which data...
3
by: sheldonlg | last post by:
I have a page that has three submit buttons. Depending upon which one was clicked, I process it differently on the server in php. One of those buttons is a delete action so I would like to add an...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.