Are you sure?-standardized function?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Oliver Spiesshofer

    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($ite m)
    {

    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

  • Erwin Moller

    #2
    Re: Are you sure?-standardized function?

    Oliver Spiesshofer wrote:
    [color=blue]
    > 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($ite m)
    > {
    >
    > 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[/color]

    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="checkD elete()">

    function checkDelete(){
    if (confirm("are you sure?")) {
    document.forms["formnamehe re"].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

    Comment

    • Erwin Moller

      #3
      Re: Are you sure?-standardized function?

      typocorrection:
      [color=blue]
      > 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.
      > }
      > }
      > ?>[/color]

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

      Comment

      • Chung Leong

        #4
        Re: Are you sure?-standardized function?

        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" <oliver@email.c om> napisal w wiadomosci
        news:Xns94A1790 A0862Boliverema ilch@63.223.5.2 54...[color=blue]
        > 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($ite m)
        > {
        >
        > 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[/color]
        question.[color=blue]
        > As far as I found out, this is difficult since you need two steps to get[/color]
        an[color=blue]
        > answer from a html page. If there any standard way how to do this?
        >
        > thanks
        >
        > Oliver
        >[/color]


        Comment

        • Stephen Poley

          #5
          Re: Are you sure?-standardized function?

          On Wed, 03 Mar 2004 12:19:06 +0100, Erwin Moller
          <since_humans_r ead_this_I_am_s pammed_too_much @spamyourself.c om> wrote:
          [color=blue]
          >Oliver Spiesshofer wrote:
          >[color=green]
          >> I want to make a standard-function that handles "Are you sure"-type
          >> questions.[/color][/color]
          [color=blue]
          >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="checkD elete()">
          >
          >function checkDelete(){
          >if (confirm("are you sure?")) {
          > document.forms["formnamehe re"].submit();[/color]

          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


          Comment

          Working...