So I've got this Example for you:
http://jsfiddle.net/mwpmk9kk/1/
As you can see, i summarize the Values of all checkboxes into one readonly input field.
Now i want to echo the Value of all selected Checkboxes into an .php-Site after submitting it (method="post").
I already tried it with echo $_POST['price'];
but that did not work.
Thank you in advance
Try this:
<?php
print "CONTENT_TYPE: " . $_SERVER['CONTENT_TYPE'] . "<BR />";
$data = file_get_contents('php://input');
print "DATA: <pre>";
var_dump($data);
var_dump($_POST);
print "</pre>";
?>
If the raw input ($data) is not empty have a look at your php.ini and check these paramters
enable_post_data_reading "1" PHP_INI_PERDIR Available since PHP 5.4.0
post_max_size "8M" PHP_INI_PERDIR PHP_INI_SYSTEM in PHP <= 4.2.3. Available since PHP 4.0.3.
A frequent error is post_max_size=x MB instead of post_max_size=x M
Try this... I've tested in a self submitting form like below and the $_POST['price'] is showing the value of the price in the text field.
<?php
if(isset($_POST['price'])){print_r($_POST['price']); }
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="checkbox" id="cb0" onclick="UpdateCost()" name="Example1" value="5"> Text 1<br />
<input type="checkbox" id="cb1" onclick="UpdateCost()" name="Example2" value="10"> Text 2<br />
<input type="checkbox" id="cb2" onclick="UpdateCost()" name="Example3" value="15"> Text 3<br />
<input type="checkbox" id="cb3" onclick="UpdateCost()" name="Example4" value="20"> Text 4<br />
<input type="checkbox" id="cb4" onclick="UpdateCost()" name="Example5" value="25"> Text 5<br />
<input type="checkbox" id="cb5" onclick="UpdateCost()" name="Example6" value="30"> Text 6<br /><br />
<input type="text" id="totalcost" name="price" placeholder="Price" readonly size="5" value="">
<input type="submit" value="submit" name="submit" />
</form>
hope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.