Count of checkboxes (again)

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

    Count of checkboxes (again)

    Okay, I'm still stuck with this problem. Here's a quick recap/summary :-

    1. Page 1:User checks 3 out of 10 checkboxes and submits form to page 2
    2. Page 2:Item count shows 3 items. User checks an additional 2
    checkboxes and presses Update button. Item count now shows 5 checkboxes
    are checked and "New" checkboxes remain checked.
    3. Page 2:User is happy and submits form to page 3
    4. Page 3:Form items are converted into printable text/data

    Pedro Graca very kindly offered a solution using "header('Locati on:
    <URL>')" which very nearly worked however my problem is that the form
    data needs to be posted to the page 3 when the user is done (if not for
    this then the solution was perfect). Using header() does not post the
    data and from what I have read elsewhere there is no way of making it do
    this.

    I can think of a really ugly solution by way of changing the form's
    action to page 3 the first time the Submit (to page 3) button is pressed
    and tell the user to press it again to get to page 3 but I don't like
    this much.

    By the way, I really would prefer to avoid JavaScript.

    Does anyone have any pointers on how I'm going to achieve this?

    Thanks in advance for any help,

    Pete.

  • Pedro Graca

    #2
    Re: Count of checkboxes (again)

    Pete wrote:[color=blue]
    > Okay, I'm still stuck with this problem. Here's a quick recap/summary :-
    >
    > 1. Page 1:User checks 3 out of 10 checkboxes and submits form to page 2
    > 2. Page 2:Item count shows 3 items. User checks an additional 2
    > checkboxes and presses Update button.[/color]

    This will post back to page2, right?
    [color=blue]
    > Item count now shows 5 checkboxes
    > are checked and "New" checkboxes remain checked.
    > 3. Page 2:User is happy and submits form to page 3
    > 4. Page 3:Form items are converted into printable text/data[/color]

    This look fine!
    [color=blue]
    > Pedro Graca very kindly offered a solution using "header('Locati on:
    ><URL>')"[/color]

    I don't remember what was your original problem
    [color=blue]
    > which very nearly worked however my problem is that the form
    > data needs to be posted to the page 3 when the user is done (if not for
    > this then the solution was perfect).[/color]

    Doesn't page 2 have two buttons?
    One for "Update" and another for "Submit" ?

    [ Ah! maybe this was your original problem ]
    [ Both buttons post back to page2 ]
    [color=blue]
    > Using header() does not post the
    > data and from what I have read elsewhere there is no way of making it do
    > this.[/color]

    I don't think so. But you can save the values in page2 (*), redirect to
    page3 and access the values there when the "Submit" button was pressed.

    (*) save them in a database, session variables, or file.
    In page3, get the values from the database, access the session variables
    or read the file.
    [color=blue]
    > I can think of a really ugly solution by way of changing the form's
    > action to page 3 the first time the Submit (to page 3) button is pressed
    > and tell the user to press it again to get to page 3 but I don't like
    > this much.[/color]

    Ugh! this sucks! What if the user wants to change the values three
    times? :)
    --
    --= my mail box only accepts =--
    --= Content-Type: text/plain =--
    --= Size below 10001 bytes =--

    Comment

    • Pete

      #3
      Re: Count of checkboxes (again)

      Pedro Graca wrote:[color=blue]
      > Pete wrote:
      >[color=green]
      >>Okay, I'm still stuck with this problem. Here's a quick recap/summary :-
      >>
      >>1. Page 1:User checks 3 out of 10 checkboxes and submits form to page 2
      >>2. Page 2:Item count shows 3 items. User checks an additional 2
      >>checkboxes and presses Update button.[/color]
      >
      >
      > This will post back to page2, right?[/color]

      Yes, this will post back to page 2
      [color=blue]
      >
      >[color=green]
      >>Item count now shows 5 checkboxes
      >>are checked and "New" checkboxes remain checked.
      >>3. Page 2:User is happy and submits form to page 3
      >>4. Page 3:Form items are converted into printable text/data[/color]
      >
      >
      > This look fine!
      >
      >[color=green]
      >>Pedro Graca very kindly offered a solution using "header('Locati on:
      >><URL>')"[/color]
      >
      >
      > I don't remember what was your original problem
      >
      >[color=green]
      >>which very nearly worked however my problem is that the form
      >>data needs to be posted to the page 3 when the user is done (if not for
      >>this then the solution was perfect).[/color]
      >
      >
      > Doesn't page 2 have two buttons?
      > One for "Update" and another for "Submit" ?
      >
      > [ Ah! maybe this was your original problem ]
      > [ Both buttons post back to page2 ]
      >[/color]

      I wanted Update to post back to page 2 and Submit to post to page 3. I
      think this is why you suggested using "header(locatio n...)".
      [color=blue][color=green]
      >>Using header() does not post the
      >>data and from what I have read elsewhere there is no way of making it do
      >>this.[/color]
      >
      >
      > I don't think so. But you can save the values in page2 (*), redirect to
      > page3 and access the values there when the "Submit" button was pressed.
      >
      > (*) save them in a database, session variables, or file.
      > In page3, get the values from the database, access the session variables
      > or read the file.[/color]

      I have got some session variables in use which pick up the posted values
      from the form and these work when posting back to page 2.
      [color=blue]
      >[color=green]
      >>I can think of a really ugly solution by way of changing the form's
      >>action to page 3 the first time the Submit (to page 3) button is pressed
      >>and tell the user to press it again to get to page 3 but I don't like
      >>this much.[/color]
      >
      >
      > Ugh! this sucks! What if the user wants to change the values three
      > times? :)[/color]

      Exactly!!! I think that I am trying to pamper the users to much by
      coding for every combination of events that could happen. Maybe if I
      just tell them that if they change the details then they must press the
      Update button *before* they press the Submit button otherwise the
      details submitted to page 3 will not have changed. That way I just use
      the session variables on page 3 rather than trying to find some way to
      get at the form details.

      So I guess it was me making things too complicated for myself that was
      the problem :-)

      Thanks for your help with this.

      Pete.

      Comment

      • Geoff Berrow

        #4
        Re: Count of checkboxes (again)

        I noticed that Message-ID:
        <gLy4c.6268$2s5 .5616@news-binary.blueyond er.co.uk> from Pete contained
        the following:
        [color=blue][color=green]
        >> Ugh! this sucks! What if the user wants to change the values three
        >> times? :)[/color]
        >
        >Exactly!!! I think that I am trying to pamper the users to much by
        >coding for every combination of events that could happen. Maybe if I
        >just tell them that if they change the details then they must press the
        >Update button *before* they press the Submit button otherwise the
        >details submitted to page 3 will not have changed. That way I just use
        >the session variables on page 3 rather than trying to find some way to
        >get at the form details.
        >
        >So I guess it was me making things too complicated for myself that was
        >the problem :-)[/color]

        Forgive me, but I have only glanced at this but why not do it all on the
        same page? The user can change their mind as many times as they want
        then.

        --
        Geoff Berrow (put thecat out to email)
        It's only Usenet, no one dies.
        My opinions, not the committee's, mine.
        Simple RFDs http://www.ckdog.co.uk/rfdmaker/

        Comment

        • Pedro Graca

          #5
          Re: Count of checkboxes (again)

          Pete wrote:[color=blue]
          > Pedro Graca wrote:[color=green]
          >>
          >> Ugh! this sucks! What if the user wants to change the values three
          >> times? :)[/color]
          >
          > Exactly!!! I think that I am trying to pamper the users to much by
          > coding for every combination of events that could happen. Maybe if I
          > just tell them that if they change the details then they must press the
          > Update button *before* they press the Submit button otherwise the
          > details submitted to page 3 will not have changed. That way I just use
          > the session variables on page 3 rather than trying to find some way to
          > get at the form details.
          >
          > So I guess it was me making things too complicated for myself that was
          > the problem :-)[/color]

          You may change the text of the "Submit" button to let your users know
          exactly what they are submitting, for example with "Submit $20.33"

          I'd do what you are trying to do with two pages (well, three, but one is
          'hidden')


          page1.php (form with two differently named submit buttons)
          <form ...action="hidd enpage.php">
          <input ...> // use session data for defaults
          <input type="submit" name="Update" value="Update"/>
          <input type="submit" name="submit" value="Submit $20.33"/>
          </form>


          hiddenpage.php (deal with POST and redirect)
          <?php
          if ($_SERVER['REQUEST_METHOD '] != 'POST') {
          header('Locatio n: page1.php'); // should be full URL
          exit('Redirecte d to <a href="page1.php ">page1</a>.');
          }
          // page was POSTed
          if (isset($_POST['submit'])) {
          // page was posted with the "Submit $20.33" button
          // update database disregarding changes, and redirect
          //
          // (or you may want to let your users change data immediately before
          // the last submit too, in which case I'd move the
          // ### change block // ### to right before this if())
          header('Locatio n: page2.php'); // should be full URL
          exit('Redirecte d to <a href="page2.php ">page2</a>.')
          }
          // page was POSTed with the "Update" button

          ### change block ###
          // change values from the POSTed data (probably in session vars)
          ### change block ###

          // and redirect to page1 which will appear updated
          header('Locatio n: page1.php'); // should be full URL
          exit('Redirecte d to <a href="page1.php ">page1</a>.');
          ?>

          page2.php (the final submit page)
          <?php
          echo '<div class="thankyou ">Thanks for submitting your data.</div>';
          echo '<div class="summary" >';
          // ...
          echo '<p>The total was $20.33</p>';
          echo '</div>';
          ?>


          HTH
          --
          --= my mail box only accepts =--
          --= Content-Type: text/plain =--
          --= Size below 10001 bytes =--

          Comment

          Working...