Skip to content
Advertisement

My PHP not processing input from radio buttons

EDIT: Some more searching on the wide web led me to this… Later on, in my form, I disable these radio buttons to prevent users from changing their previous answers after some time… Is it possible that the PHP is not reading the diasabled buttons?
How should I then prevent the change of radio button states AND still have readable radios?


I’ve been searching through related questions but it seems none of them covers the same problem I’m dealing with…

First, a short snippet of my form:

JavaScript

I’d like to precess the data with this PHP below:

JavaScript

The problem is that this code is perfectly processing the <select> field (many of them, actually; plus some text fields) BUT fails to even read any (neither the pre-checked nor any other clickable) input from the <input type="radio">

JavaScript

The first echo perfectly displays the selected value but the second one does not return a thing no matter wat I click, or change on checked / not checked options in the HTML above.

Any good advices?

What am I missing? What should I change? How to get this radio-reading-PHP fixed?

Many thanks!

Advertisement

Answer

Just setting the radio buttons to readOnly might be enough for your purposes, but if you need to disable the buttons then you can still read the checked status in JavaScript. If you do that you can assemble the form data in a FormData object and send it with AJAX instead of using the browser’s submit.

Here’s a proof of concept based on your question and comments above.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement