Jump to content

The14thGOD

Members
  • Posts

    256
  • Joined

  • Last visited

    Never

Everything posted by The14thGOD

  1. Heh, that's pretty intimidating lol. I may wait till Monday to talk to my teacher since this project I'm working on isn't due till Tuesday. Thanks for your help, The14thGOD
  2. Would I just replace the $_POST with $_SESSION? Or would there be more code? I have no idea how too process the info from the same page :(. I've heard you can do 2 actions, but I don't even know how to do that either. The14thGOD
  3. I just tried this code and sadly it did not work. action code [code] $q1_1_check = ($_POST['question[1]']=='1') ? 'checked' : ''; $q1_2_check = ($_POST['question[1]']=='2') ? 'checked' : ''; $q1_3_check = ($_POST['question[1]']=='3') ? 'checked' : ''; $q1_4_check = ($_POST['question[1]']=='4') ? 'checked' : ''; [/code] radio button: [code] <td colspan="2"><span class="question">Question 01: The "devine-command-theory" holds that?</span><br /> <input type="radio" name="question[1]" value="1" <? echo $q1_1_check; ?> />A: Certain things are good for us because it says so in the Bible.<br /> <input type="radio" name="question[1]" value="2" <? echo $q1_2_check; ?> />B: Certain actions are right because they are modeled after Jesus.<br /> <input type="radio" name="question[1]" value="3" <? echo $q1_3_check; ?> />C: Certain actions are right because they are what God wills.<br /> <input type="radio" name="question[1]" value="4" <? echo $q1_4_check; ?> />D: Certain actions are divine because they are inherently good. </td> [/code] Any idea why? So after I hit the submit button, it goes to calculate.php, as I call it, and it goes through that and then after that it checks to see if all questions are answered, if not, then it should come back to the index.php page, and it says my error that it should (please answer question 2) but the question 1 field is still left blank. Thanks again for any help. The14thGOD
  4. Alright dude, thanks. Ill try this out and see if it helps me. I think I'm going to try a for loop so it shortens up the code a lot. Thanks again, The14thGOD
  5. [quote author=bljepp69 link=topic=117932.msg481544#msg481544 date=1165634190] Here's a method I've used to keep the radio button selections during form processing. Set up the radio buttons like this: [code] <input type="radio" name="radio1" value="Y" <?php echo $ry_check; ?>>Yes <input type="radio" name="radio1" value="N" <?php echo $rn_check; ?>>No [/code] Then use something like this in your form processing. [code] <?php   $ry_check = ($_POST['radio1']=='Y') ? 'checked' : '';   $rn_check = ($_POST['radio1']=='N') ? 'checked' : ''; ?> [/code] That should keep the values selected by the user. [/quote] I have 20 questions with 4 options. So should my code be something like this for radio buttons: [code] <input type="radio" name="question[2]" value="1" <? echo $q2_1_check ?> />A: Epistomology.<br /> <input type="radio" name="question[2]" value="2" <? echo $q2_2_check ?> />B: Hermeneutics.<br /> <input type="radio" name="question[2]" value="3" <? echo $q2_3_check ?> />C: Ontology.<br /> <input type="radio" name="question[2]" value="4" <? echo $q2_4_check ?> />D: Metaphysics. [/code] And then in the form action: [code]   $q2_1_check = ($_POST['question[2]']=='1') ? 'checked' : '';   $q2_2_check = ($_POST['question[2]']=='2') ? 'checked' : '';   $q2_3_check = ($_POST['question[2]']=='3') ? 'checked' : '';   $q2_4_check = ($_POST['question[2]']=='4') ? 'checked' : ''; [/code] I probably should have showed how these were set up in the first place, and I apologize for that. Also if you don't mind, could you explain this a bit. I've never seen this format, or used the post. But if I had to guess, i would say, $_POST gets the value of the input type, in this case a radio button, and if it's equal to 'x' make the variable equal to checked, if not it leaves it blank? Thanks again for the help, The14thGOD
  6. Hey, I have a quiz form that I made for a class. Once the user submits, my php script checks to see if the answers are all filled out. If not it sends them back to the form. However, the information is not repopulated, forcing the user to re-answer all the questions. I have some fields working but I'm not sure how to get the radio buttons to work. I have an idea but if anyone has a suggestion as to what is more efficient that would be cool too. The method I am trying to do is to store the values in cookies. Here's the code in my action script: [code]for($y=1; $y<21; ++$y) { setcookie("question[$y]", $question[$y]); }[/code] I don't think that is working though because when I try to echo the value of the cookie, I get nothing. The code looks right to me..since it matches the setcookie code I have above that, and it works. Unless I am not able to have a variable in the name of the cookie? Now once I get that working I was going to do this, this is the part I think is inefficient: [code]<? if($_COOKIE['question[1]'] == 1) { echo(" checked "); } ?> [/code] I would have to do that for each of my four options on all 20 questions ^_^. I just learned PHP in this last quarter of class and we didn't touch on cookies too much. So any help would be much appreciated. Thanks in advance, The14thGOD btw, sorry for the bad code format, I've never posted code before ^_^.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.