Jump to content

Submit Form -> Radio Buttons left unselected don't send


Bhayes21

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.