472,981 Members | 1,151 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,981 software developers and data experts.

Updating a count of checkboxes that are checked

There is a Summary/Example further down...

On page one of my site I have a form with some checkboxes and detailed
descriptions. When the form is submitted (to page two), the values of
the checkboxes are picked up using $_POST and put into session
variables. On page two there is another form which is simply a
condensed version of the previous one (titles with no descriptions).
The checkboxes are named the same on both forms.

When page two loads and the posted variables have been put into session
variables, my PHP script loops through the session variables and sets
the checkboxes on the form to checked where there is a corresponding
session variable set. I also have a variable which counts how many of
the checkboxes are checked. This is incremented when a session variable
that is set (checkbox will be checked) is encountered. So far, so good
as this all works with no problems.

Now to the problem. I need the users to be able to check/uncheck the
checkboxes on page two if they change their mind or made a mistake on
page one. If they amend any checkboxes then they can press an Update
button to update the count variable.

Normally I would achieve this by posting the form back to the page
containing the script however once the form on page two is finalised, it
needs to be posted to a third page which lays out the data for printing.
This does not use form items so the third page is necessary.

Example of what I need/Summary of my waffle above:

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

Is there a way to submit a form to one location if one button is pressed
and another location if a second button is pressed? I'm guessing "No"
as a form's "action" can only be one location.

Any ideas?

Thanks in advance,

Pete.

Jul 17 '05 #1
2 3922
Pete wrote:
Is there a way to submit a form to one location if one button is pressed
and another location if a second button is pressed? I'm guessing "No"
as a form's "action" can only be one location.


You can name your submit buttons differently and act on which button was
pressed.

<input type="submit" name="sumbit" value="Preview">
<input type="submit" name="sumbit" value="Go!">
<!-- this misspelling ^^^^^^ was deliberate :) -->

and the receiving PHP could do

<?php
// save $_POST data
$_SESSION['postdata'] = $_POST;
switch ($_POST['sumbit']) {
case 'Preview' : $URL = 'http://www.example.com/page1.php';
break;
case 'Go!': $URL = 'http://www.example.com/page2.php';
break;
default: $URL = false;
}
if ($URL) {
header('Location: ' . $URL);
exit('Redirected <a href="' . $URL . '">here</a>.');
} else {
// Uh Oh, someone must have been playing with my form
}
?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
In article <DV***************@news-binary.blueyonder.co.uk>,
Pete <skredding_no_spam_you_tw@s_netscape.net> wrote:
There is a Summary/Example further down...

On page one of my site I have a form with some checkboxes and detailed
descriptions. When the form is submitted (to page two), the values of
the checkboxes are picked up using $_POST and put into session
variables. On page two there is another form which is simply a
condensed version of the previous one (titles with no descriptions).
The checkboxes are named the same on both forms.

When page two loads and the posted variables have been put into session
variables, my PHP script loops through the session variables and sets
the checkboxes on the form to checked where there is a corresponding
session variable set. I also have a variable which counts how many of
the checkboxes are checked. This is incremented when a session variable
that is set (checkbox will be checked) is encountered. So far, so good
as this all works with no problems.

Now to the problem. I need the users to be able to check/uncheck the
checkboxes on page two if they change their mind or made a mistake on
page one. If they amend any checkboxes then they can press an Update
button to update the count variable.

Normally I would achieve this by posting the form back to the page
containing the script however once the form on page two is finalised, it
needs to be posted to a third page which lays out the data for printing.
This does not use form items so the third page is necessary.

Example of what I need/Summary of my waffle above:

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

Is there a way to submit a form to one location if one button is pressed
and another location if a second button is pressed? I'm guessing "No"
as a form's "action" can only be one location.


<input type='submit' value='Send'
onClick="document.form.action='page.php';document. form.submit();" />
<input type='submit' value='Next'
onClick="document.form.action='form2.php';document .form.submit();" />

That should do it. But you should ask in a JavaScript group.

--
Sandman[.net]
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Pete | last post by:
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...
4
by: Laura | last post by:
Here's the situation: I'm trying to use an update query to copy data from one row to another. Here is the situation: I have 5 companies that are linked to each other. I need to show all 5...
0
by: willow1480 | last post by:
I am developing a small little Service Control Application. I am using a listview control with checkboxes and getting the list of services I want to control from a text file. When you check a...
0
by: dan_williams | last post by:
I have an ASP.NET web page with a CheckBoxList which users can select multiple checkboxes and select to save, which inserts a record/row for each checkbox ticked into an SQL database. What is...
1
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file...
4
by: haresh.amis | last post by:
hello to all, I m using .net 2.0 and i face a problem that is as under Well I have a checkboxlist which i bound in .cs page now I want to count that how many checkboxes ate checked ( In...
10
by: chimambo | last post by:
Hi All, I have a little problem. I am retrieving records from a table and I want to update the records using checkboxes. I am able to display the database record quite alright and I have created...
0
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td...
14
by: zufie | last post by:
I have to create a QA report regarding callers calling into a phone hotline. The report consists of many checkboxes such as: Did the IBCCP agency contact you? Yes/NO How many days passed...
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
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
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...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
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.