Answered
checkboxes and array
This should be fairly simple but I am stumped...
???I want to display a question and 9 answers with checkboxes which are dynmically checked by an array.
On a form I have a table which has a question and 9 answers (checkboxes)
The checkboxes have the same name (Answer5) so it creates an array when submitted to the results page
Below is the code for the table with the question and answers:
<table width="400" cellpadding="0" cellspacing="0">
<tr><td colspan="2">My Question goes here ?</td></tr>
<tr><td><label> <input type="checkbox" name="Answer5" value="Bedroom Addition">Bedroom Addition</label></td></tr>
<tr><td><label><input type="checkbox" name="Answer5" value="Family room Addition">Family room Addition</label></td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Garage Addition">Garage Addition</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Solarium/Greenhouse">Solarium/Greenhouse</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Guest Suite">Guest Suite</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Sunroom">Sunroom</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Out Building">Out Building</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Pool Enclosure">Pool Enclosure</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="2nd Story Addition">2nd Story Addition</td></tr>
</table>
When I click submit it goes to a results page and prints the array.
Below is the code for printing the array:
<?php print_r($HTTP_POST_VARS['Answer5']); ?>
And it displays:
Array ( [0] => Bedroom Addition [1] => Garage Addition )
when i check those checkboxes.
???Instead of displaying the array --its just there for error checking for now--
???I want to display the same table with the question and 9 answers on the results page with the checkboxes that were selected on the previous page
The way I am actually using this is to submit the array to a database. Then have another page the retrieves the array from the database to view the results. I simplified this a bit to get the functionality working right.
I'm stumped! Please Help! Thanks!
when I submit it goes to a results page which simply displays the result
the result is an array.
???I want to display a question and 9 answers with checkboxes which are dynmically checked by an array.
On a form I have a table which has a question and 9 answers (checkboxes)
The checkboxes have the same name (Answer5) so it creates an array when submitted to the results page
Below is the code for the table with the question and answers:
<table width="400" cellpadding="0" cellspacing="0">
<tr><td colspan="2">My Question goes here ?</td></tr>
<tr><td><label> <input type="checkbox" name="Answer5" value="Bedroom Addition">Bedroom Addition</label></td></tr>
<tr><td><label><input type="checkbox" name="Answer5" value="Family room Addition">Family room Addition</label></td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Garage Addition">Garage Addition</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Solarium/Greenhouse">Solarium/Greenhouse</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Guest Suite">Guest Suite</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Sunroom">Sunroom</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Out Building">Out Building</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="Pool Enclosure">Pool Enclosure</td></tr>
<tr><td><input type="checkbox" name="Answer5" value="2nd Story Addition">2nd Story Addition</td></tr>
</table>
When I click submit it goes to a results page and prints the array.
Below is the code for printing the array:
<?php print_r($HTTP_POST_VARS['Answer5']); ?>
And it displays:
Array ( [0] => Bedroom Addition [1] => Garage Addition )
when i check those checkboxes.
???Instead of displaying the array --its just there for error checking for now--
???I want to display the same table with the question and 9 answers on the results page with the checkboxes that were selected on the previous page
The way I am actually using this is to submit the array to a database. Then have another page the retrieves the array from the database to view the results. I simplified this a bit to get the functionality working right.
I'm stumped! Please Help! Thanks!
when I submit it goes to a results page which simply displays the result
the result is an array.
