Hello and thanks. have a html form with 1210 checkboxes that define item description, number and price. would like to find a PHP script that reads these values when the checkbox is checked and then creates and displays a pre-filled order form with Item number, description, unit price and adds a text box where the user can select quantity.
each item checkbox data looks like this ... -
-
<input type="checkbox" name="C04001" id="C04001" value=1 descrip="size, color, partnum, weight, class, texture, hardware" item="04001" rice="4.97" onclick="totalCheckboxes(this);" readonly>
-
-
we are totaling checkboxes on page one and may use a form mailer to track interest, but we really need the second page running on our web server.
thanks again for your help.
18 1878
Heya, txguy.
When a checkbox is submitted with form data, it will not show up at all if it is unchecked, and it will be included with a value of 'ON' if it is checked.
Probably your best bet would be to create a sub-array and then loop through it: -
<!-- --------------------------¬ -->
-
<input type="checkbox" name="parts[C04001]" id="C04001" value=1 descrip="size, color, partnum, weight, class, texture, hardware" item="04001" rice="4.97" onclick="totalCheckboxes(this);" readonly="readonly" />
-
Then in your PHP: -
foreach( $_POST['parts'] as $name => $checked )
-
{
-
// Output / Processing goes here.
-
-
// Debug
-
echo $name, '<br />';
-
}
-
adding the element name change to htm page one works ok, and I have created a html page two with the following php ... -
-
<?php
-
-
$Item=$_GET["item"];
-
$Description=$_GET["descrip"];
-
$UnitPrice=$_GET["price"];
-
$SubTotal=$_GET["AllColstotal"];
-
-
foreach( $_POST['parts'] as $name => $checked )
-
{
-
-
// Output / Processing goes here.
-
-
<!--- ORDER FORM --->
-
-
}
-
-
?>
-
-
but it doesnt post from page one.
how should the submit line read on page one??
Heya, TX.
You'll need to make sure that each checkbox is named properly: -
<input type="checkbox" name="parts[C04001]" ... />
-
<input type="checkbox" name="parts[C04002]" ... />
-
.
-
.
-
.
-
For more information, have a look at this document.
got that part thanks ... I have updated all pageone names to include "parts[xxxxx] and have page one is working fine ... I've built page two with the php code in the top with the table layout and input field names using the $name and the loop function you recommended ... I've saved this file as both name.php and name.htm neither or working ... my form instruction on page one and my submit are as follows ... -
-
<form action="pop.php"method="post">
-
and also tried it this way
-
<form action="pop.htm"method="post">
-
-
<input type="submit">
-
-
why wont the submit button call page two????????
thanks
Heya, TX.
What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
when I try -
-
<?php
-
echo $_POST['descrip'];
-
echo $_REQUEST['price'];
-
-
import_request_variables('p', 'p_');
-
echo $p_descrip;
-
-
-
?>
-
all I get is the form with no data.
thanks
Heya, TXGuy.
Try this:
to see what, if any, input you're getting from the form.
with the following as my second page ... -
<?php
-
$descrip = $_POST['descrip'];
-
$price = $_POST['price'];
-
-
echo $descrip, '<br />';
-
-
print_r($_POST);
-
-
import_request_variables('p', 'p_');
-
echo $p_descrip;
-
-
echo "You ordered ". $descrip . " " . $price . ".<br />";
-
echo "WOOHOO!";
-
-
?>
I get the java produced totals from page one -
Array ( [AllColscount] => 1 [selections] => Tarps [AllColstotal] => $ 68.77 [Col01count] => 0 [Col02count] => 0 [Col03count] => 0 [Col04count] => 0 [Col05count] => 0 [Col06count] => 0 [Col07count] => 1 [Col08count] => 0 [Col09count] => 0 [Col10count] => 0 [C07079] => 1 [Col01total] => 0.00 [Col02total] => 0.00 [Col03total] => 0.00 [Col04total] => 0.00 [Col05total] => 0.00 [Col06total] => 0.00 [Col07total] => 68.77 [Col08total] => 0.00 [Col09total] => 0.00 [Col10total] => 0.00 [AllColscountsum] => 1 [AllColstotalsum] => $ 68.77 [view_x] => 26 [view_y] => 11 ) You ordered .
-
WOOHOO!
-
none of the checkbox data, checked or unchecked is coming thru
?????
Heya, TX.
$_POST is not persistent. Your checkbox data will only be available to the page you're submitting the form to.
Try adding this to the top of your first page: -
session_start();
-
foreach( $_POST as $_key => $_val )
-
{
-
$_SESSION[$_key] => $_val;
-
}
-
And at the top of page two: -
session_start();
-
print_r($_SESSION);
-
got the following
Parse error: syntax error, unexpected T_DOUBLE_ARROW on line 9 -
<html>
-
<head>
-
-
-
<?php
-
session_start();
-
foreach( $_POST as $_key => $_val )
-
{
-
$_SESSION[$_key] => $_val;
-
}
-
?>
-
-
Heya, TX.
got the following
Parse error: syntax error, unexpected T_DOUBLE_ARROW on line 9
Oops. Sorry about that. Try this: -
<html>
-
<head>
-
-
-
<?php
-
session_start();
-
foreach( $_POST as $_key => $_val )
-
{ // No > here ----¬
-
$_SESSION[$_key] = $_val;
-
}
-
?>
-
-
thanks very much for your help.
got a session error
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/ihh-2693/it-happens-here-www/test/st/sct-00.php:5) in /home/ihh-2693/it-happens-here-www/test/st/sct-00.php on line 6
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ihh-2693/it-happens-here-www/test/st/sct-00.php:5) in /home/ihh-2693/it-happens-here-www/test/st/sct-00.php on line 6
heres the code from page1 -
<html>
-
<head>
-
-
-
<?php
-
session_start();
-
foreach( $_POST as $_key => $_val )
-
{
-
$_SESSION[$_key] = $_val;
-
}
-
?>
-
-
<script type="text/javascript">
-
-
-
-
function totalCheckboxes(checkField) {
-
-
//Determine the column
-
var column = checkField.name.substr(1,2);
-
-
var columnTotal = 0;
-
var columnCount = 0;
-
-
//Itterate through all the checkboxes in the column
-
for (i=1; i<=110; i++) {
-
-
var row = '00'+i;
-
fieldID = 'C'+column+row.substr(row.length-3)
-
-
//only check fields that exist
-
if (chkObj = document.getElementById(fieldID)) {
-
-
//Add price if field is checked
-
if (chkObj.checked) {
-
columnCount++;
-
columnTotal = parseFloat(columnTotal) + parseFloat(chkObj.price);
-
}
-
}
-
-
}
-
-
//Enter the totals for the current column
-
document.getElementById('Col'+column+'count').value = columnCount;
-
document.getElementById('Col'+column+'total').value = columnTotal.toFixed(2);
-
-
//Add the totals from each column
-
var grandTotal = 0;
-
var grandCount = 0;
-
for (i=1; i<=10; i++) {
-
column = (i<10)?'0'+i:i;
-
columnCount = document.getElementById('Col'+column+'count').value;
-
columnTotal = document.getElementById('Col'+column+'total').value;
-
-
grandCount = parseFloat(grandCount) + parseFloat((columnCount)?columnCount:0);
-
grandTotal = parseFloat(grandTotal) + parseFloat((columnTotal)?columnTotal:0);
-
}
-
-
//Enter the grand totals
-
document.getElementById('AllColscount').value = grandCount;
-
document.getElementById('AllColstotal').value = "$ "+grandTotal.toFixed(2);
-
-
document.getElementById('AllColscountsum').value = grandCount;
-
document.getElementById('AllColstotalsum').value = "$ "+grandTotal.toFixed(2);
-
-
}
-
-
-
</script>
-
-
-
</head>
-
-
<body bgcolor="#FFFFCE">
-
Heya, TX.
My goodness. I feel so silly making all of these mistakes that I should know better!
session_start() has to go before your script outputs anything. You'll want to do this instead, and this time, it really should work :P -
<?php
-
session_start();
-
foreach( $_POST as $_key => $_val )
-
{
-
$_SESSION[$_key] = $_val;
-
}
-
?>
-
<html>
-
<head>
-
.
-
.
-
.
-
thanks, page1 works but get the following from page2 ...
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/ihh-2693/it-happens-here-www/test/st/popchecks.php:3) in /home/ihh-2693/it-happens-here-www/test/st/popchecks.php on line 5
Array ( ) Array ( [AllColscount] => 2 [selections] => Tarps [AllColstotal] => $ 147.20 [Col01count] => 0 [Col02count] => 0 [Col03count] => 1 [Col04count] => 1 [Col05count] => 0 [Col06count] => 0 [Col07count] => 0 [Col08count] => 0 [Col09count] => 0 [Col10count] => 0 [C03074] => 1 [C04074] => 1 [Col01total] => 0.00 [Col02total] => 0.00 [Col03total] => 73.60 [Col04total] => 73.60 [Col05total] => 0.00 [Col06total] => 0.00 [Col07total] => 0.00 [Col08total] => 0.00 [Col09total] => 0.00 [Col10total] => 0.00 [AllColscountsum] => 2 [AllColstotalsum] => $ 147.20 [view_x] => 17 [view_y] => 7 )
here's page2 code -
<html><body>
-
-
<?php
-
-
session_start();
-
-
print_r($_SESSION);
-
-
print_r($_POST);
-
-
?>
-
-
</body></html>
-
I really appreciate your help
if I delete the
from page2, I dont get the session error, but I still dont get the input data element from page1 just the array totals from page1
Array ( [AllColscount] => 1 [selections] => Tarps [AllColstotal] => $ 149.39 [Col01count] => 0 [Col02count] => 0 [Col03count] => 0 [Col04count] => 0 [Col05count] => 1 [Col06count] => 0 [Col07count] => 0 [Col08count] => 0 [Col09count] => 0 [Col10count] => 0 [C05079] => 1 [Col01total] => 0.00 [Col02total] => 0.00 [Col03total] => 0.00 [Col04total] => 0.00 [Col05total] => 149.39 [Col06total] => 0.00 [Col07total] => 0.00 [Col08total] => 0.00 [Col09total] => 0.00 [Col10total] => 0.00 [AllColscountsum] => 1 [AllColstotalsum] => $ 149.39 [view_x] => 22 [view_y] => 3 )
????????
Heya, TX.
Similarly to page 1, on page 2, you have to call session_start() before your script outputs anything.
eliminated the html code, just php and I only get the original array values for the total functions from page1, stil dont get the checkbox element values; descrip, price, name
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Kevin Lyons |
last post by:
Hello,
I am trying to get my select options (courses) passed correctly from
the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html
I am having difficulty getting the...
|
by: Mel |
last post by:
Are we going backwards ? (please excuse my spelling...)
In my opinion an absolute YES !
Take a look at what we are doing ! we create TAGS, things like <H1> etc.
and although there are tools...
|
by: Rithish |
last post by:
I want to emulate paging in an HTML document. something like,
-------------------------
| |
| <DIV> |
| |
| <TABLE></TABLE>...
|
by: Luke |
last post by:
Elements with name attribute:
form, input, textarea, a, frame, iframe, button, select, map, meta,
applet, object, param, img (if you know more reply...)
Methods of addresing html elements:...
|
by: Brian Kitt |
last post by:
I have a C# application that builds dynamic HTML and renders it. Because it
is rendered in this way, the input controls are not server controls. I write
the entire page, which has a variable...
|
by: VK |
last post by:
I wandering about the common proctice of some UA's producers to spoof
the UA string to pretend to be another browser (most often IE).
Shouldn't it be considered as a trademark violation of the...
|
by: Samuel Shulman |
last post by:
I would like to refer to HTML elements from my ASP.NET code do they have to
be server side
If yes then I can I set their html name for the POST method
Thank you,
Samuel
|
by: justplain.kzn |
last post by:
Hi,
I have a table with dynamic html that contains drop down select lists
and readonly text boxes. Dynamic calculations are done on change of a
value in one of the drop down select lists.
...
|
by: Atli |
last post by:
Introduction
At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |