0

Hi all

I have a checkboxes form. How can I get the results displayed (in a new window lets say) when submiting it?

Thank you

P.S. I care about getting results displayed part.

2
Contributors
8
Replies
9
Views
8 Years
Discussion Span
Last Post by Pavlos1316
0

Well, when you submit the form, only the selected checkboxes will be posted to the next page. You can see what values are being posted by using print_r($_POST['checkboxname'] You can loop through $_POST (since that will be an array of checked values) and display the data however you want !

0

This is asample of my code:

$home='unchecked';
$home2='unchecked';

if (isset($_POST['submit'])) {
if (isset($_POST['home'])) {
$home = $_POST['home'];
if ($home == 'home') {$home = 'checked';}}

I add

echo "$home";
echo"home2";

But the echo I get if i check only 'home' is: on unchecked

What sould I change to display only the checked checkboxes end with their name (home, home2, etc.).

I first tried what you said but I got nothing.

[The same as I get in my db... (but here is no problem)]

0

Is too long cause i don't have only 3 boxes.

Is just like I show above including my db connection.

STARTS LIKE I JUST POSTED [$home='unchecked';] etc
AND ENDS WITH MY ECHO.

Nothing else.

0

I don't get it. Here is a simple example.

<?php
if(isset($_POST['submit'])) {
	print_r($_POST['check']);
}
?>
<html>
<body>
<form method="post" action="checkbox.php">
<input type="checkbox" name="check[]" value="1"> 1 <br />
<input type="checkbox" name="check[]" value="2"> 2 <br />
<input type="checkbox" name="check[]" value="3"> 3 <br />
<input type="checkbox" name="check[]" value="4"> 4 <br />
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>
0

Oh.. was playing with procces.php and not the form.... I will give it a try

0

my next idea was

to replace

$home='unchecked';
with
$home='';

and

$home = 'checked';
with
$home = 'home';

0

Still no resaults with your way..

with mine replacing $home='unchecked';
with $home='';

I don't get desplayed anything when not checked. so i am ok here.

but still when is checked i get the word on..

hat do I have to change in order to get the word home or whatever i wand to get????

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.