Validate in two different groups of radio buttons

0

Hello very good afternoon I have a form of about 28 questions in which each question has two answers that is organized by groups, what I want to try is that the answers do not overlap see the attached image

I am looking for how to validate it so that as soon as they are in the same line indicate that it is not allowed, one group is for MOST responses and the other one for LEAST here I leave the mark up:

    <input type="radio" name="most_option_1" id="q1_most_option_id_1" value="D">
<input type="radio" name="least_option_1" id="q1_least_option_id_1" value="C">

I hope someone can guide me. Greetings

    
asked by Cobol 25.11.2016 в 05:21
source

2 answers

1

If you only want to be able to select a radio for each <td> in the table, you must put both the same attribute name and different value to be able to know which one you chose. The same HTML forms will ensure that the user can not choose more than radio .

Source: link

  

radio : Radio button. You must use the value attribute to defend the value that will be sent by this element. Use the checked attribute to determine if an element should be selected by default. Radio buttons that have the same value in the name attribute, are considered to be in the same "group of radio buttons", so only one option can be selected at a time.

Example:

<table border="1">
  <thead>
    <tr>
      <th>Pregunta</th>
      <th>Most</th>
      <th>Least</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Pregunta #1</td>
      <td><input type="radio" name="p1" value="M"></td>
      <td><input type="radio" name="p1" value="L"></td>
    </tr>
    <tr>
      <td>Pregunta #2</td>
      <td><input type="radio" name="p2" value="M"></td>
      <td><input type="radio" name="p2" value="L"></td>
    </tr>
    <tr>
      <td>Pregunta #3</td>
      <td><input type="radio" name="p3" value="M"></td>
      <td><input type="radio" name="p3" value="L"></td>
    </tr>
  </tbody>
</table>
    
answered by 25.11.2016 в 05:31
0

You must put the same value in "name".

  <input type="radio" name="most_option_1" id="q1_most_option_id_1" value="D">
  <input type="radio" name="most_option_1" id="q1_least_option_id_1" value="C">
    
answered by 25.11.2016 в 05:46