![]() |
|
|
|||||||
![]() |
|
|
Thread Tools | Rate Thread |
|
|
PM User | #1 |
|
Regular Coder ![]() Join Date: Mar 2007
Posts: 151
Thanks: 6
Thanked 4 Times in 4 Posts
![]() |
php explode
Hi guys. I've been getting help in the javascript forum putting together a php/javascript quiz. I had it functioning ok but it wasn't working in IE7 and they helped me rewrite it. However, before I had the variables being passed in hidden checkboxes. Now there are no checkboxes and I'm struggling with php explode as the javascript guys suggested I use.
What am I doing wrong? Code:
<form action="money_quiz_results.php" method="post"> <input type="hidden" name="userSelections"> Code:
<tr> <td>Anxious</td> <td>Prone to blame</td> <td>Highly Emotional</td> </tr> <tr> <td>Lives in the past</td> <td>Financially irresponsible</td> <td>Seeks rescue</td> </tr> PHP Code:
|
|
|
|
|
|
PM User | #3 |
|
Regular Coder ![]() Join Date: Apr 2009
Posts: 700
Thanks: 1
Thanked 163 Times in 163 Posts
![]() ![]() |
In your Javascript thread 12 Pack Mack mentioned that with his code your variables would be passed within the userSelections field as a comma delimited string, meaning what you have to do is:
$userSelections = explode(",", $_POST['userSelections']);$userSelections will then be an array holding your variables. |
|
|
|
|
|
PM User | #4 |
|
Regular Coder ![]() Join Date: Mar 2007
Posts: 151
Thanks: 6
Thanked 4 Times in 4 Posts
![]() |
Awesome, thanks for helping! I have the results page like this:
Code:
<?php
$userSelections = explode(",", $_POST['userSelections']);
$innocent = 0;
if ($_POST['anxious'] == 'yes')
$innocent++;
if ($_POST['trusting'] == 'yes')
$innocent++;
Last edited by JohnDubya; 04-28-2009 at 04:35 PM.. Reason: remove url, as requested |
|
|
|
|
|
PM User | #5 |
|
Regular Coder ![]() Join Date: Apr 2009
Posts: 700
Thanks: 1
Thanked 163 Times in 163 Posts
![]() ![]() |
$_POST will only contain 'userSelections', which should contain all your variables, so calling $_POST['something else'] doesn't do anything. Try
echo var_dump($userSelection); in order to see what's in there and how you can use it.
|
|
|
|
|
|
PM User | #8 |
|
Regular Coder ![]() Join Date: Mar 2007
Posts: 151
Thanks: 6
Thanked 4 Times in 4 Posts
![]() |
Hey awesome! Why won't it do that for me? It won't work in either Firefox or IE7. The values are always zero and the var_dump says NULL.
*the values will still be passed if there's a checkbox that's checked... |
|
|
|
|
|
PM User | #10 |
|
Regular Coder ![]() Join Date: Apr 2009
Posts: 700
Thanks: 1
Thanked 163 Times in 163 Posts
![]() ![]() |
Sorry, I mistyped.
echo var_dump($userSelections);I didn't have a look through the Javascript code though, just the comment that went with it. Last edited by venegal; 04-19-2009 at 03:12 AM.. Reason: typo |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Rate This Thread | |
|
|