Bhayes21 Posted April 9, 2012 Share Posted April 9, 2012 So I have created an online test . I have the results from the form submitted to my email. It is working great but the only problem is that when a question is left unanswered, the radio button doesn't have a result. What i want it to do is when a question is left unanswered, the email should look like this (Question) 1_01: True 1_02: Unanswered 1_03: False 1_04: Unanswered 1_05: True Right now it looks like this: (Question) 1_01: True 1_03: False 1_05: True I can't make the radio button required because it is a timed test where you have to work fast, so unanswered questions are going to happen. How do I make it so that unanswered radio buttons submit the value "unanswered" in the E-mail? Quote Link to comment Share on other sites More sharing options...
Psycho Posted April 9, 2012 Share Posted April 9, 2012 Well, as you've seen an unselected radio button will simply not be included in the POST data. Therefore, you need to create a method to handle it. Here are some options: I assume the processing script is only processing based upon what is sent. You could instead change that to process based upon what is EXPECTED. So, if you expect 10 questions, then loop through those 10 questions and check if there was a response. If not, you know it wasn't answered. If you still want to reply upon the submitted data for your processing logic, you could add a hidden field for each question for the purposes of processing. E.g. <input type="hidden" name="questions[1_01]" /> <input type="hidden" name="questions[1_02]" /> <input type="hidden" name="questions[1_03]" /> . . .[code] You can then simply loop through the "questions" array and look for the corresponding answer if one exists. Lastly, you could use some JavaScript to handle this. But, I'd advise against it since it would not be as reliable. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.