473,734 Members | 2,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3963
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('Locatio n: ' . $URL);
exit('Redirecte d <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.blueyond er.co.uk>,
Pete <skredding_no_s pam_you_tw@s_ne tscape.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="docume nt.form.action= 'page.php';docu ment.form.submi t();" />
<input type='submit' value='Next'
onClick="docume nt.form.action= 'form2.php';doc ument.form.subm it();" />

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
2982
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 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...
4
2278
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 companies on a form. 3 of the companies have common employees. I have a table that looks like this:
0
2345
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 checkbox, it should either stop the service or start the service depending on each respective service's status. I want the listView to update the status for each service as they are checked. instead all I can seem to do is clear the listView and I...
0
1044
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 the recommended practise when doing this? Is it better/easier to delete all existing records, and then reinsert new records for checkboxes checked, or to get my application to identify which checkboxes have since been unticked and delete SQL rows...
1
2603
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 exists just to sort of synchronize them by changing the xml nodes attribute(s). somehow i always catch an exception "blabla has an invalid token" but i cannot find a solution for this. maybe someone of you people can tell me how to do this...
4
22845
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 javascript ) and checked checkboxes text will be concat and that string will be pass on to report query I m trying on by this code but it's not work
10
2234
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 an array of checkboxes, but my update loop is not working. Here is my code: /*---------This retrieves the records -------------*/ if($row_md) { do{ echo "<tr><td text align='right'>";
0
3118
by: TechnoAtif | last post by:
<?php include "dbconnect.php"; include "commonFunc.php"; ?> <!----------------------------------> <table width="80%" border="1" cellpadding="2" cellspacing="0"> <tr > <td colspan="2"><p>
14
3656
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 before you heard from the agency? 1Week/2Weeks/3 or More Weeks Did you become an IBCCP client? Yes/NO/Dont Know
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3261
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.