开发者

radio button selection to be done in order

I have 4 fields,3 radio button and 1 question with its serial number in one line .i want if user clicks on answer of any question out of order, he should be alerted开发者_JAVA百科 to answer next question no. first,Suppose after answering question 1 and 2 he answers 7 question radio button,alert message should popup forcing him to answer 3 question first, also i want to save the values of radio button in database,i have 12 question in one page,and total of 180 questions are there.

<tr><td>L<input type="radio" value="L"></td> 
        <td>?<input type="radio" value="?"></td>
        <td>D<input type="radio" value="D"></td>
       <td id="1">1. Question here</td> 
    </tr>
   <tr><td>L<input type="radio" value="L"></td> 
        <td>?<input type="radio" value="?"></td>
        <td>D<input type="radio" value="D"></td>
       <td id="2">2. question Here </td> 
    </tr><tr><td>L<input type="radio" value="L"></td> 
        <td>?<input type="radio" value="?"></td>
        <td>D<input type="radio" value="D"></td>
       <td id="3">3.  Question here</td> 
    </tr><tr><td>L<input type="radio" value="L"></td> 
        <td>?<input type="radio" value="?"></td>
        <td>D<input type="radio" value="D"></td>
       <td id="4">4. Question here</td> 
    </tr><tr><td>L<input type="radio" value="L"></td> 
        <td>?<input type="radio" value="?"></td>
        <td>D<input type="radio" value="D"></td>
       <td id="5">5. Question here</td> 
    </tr><tr><td>L<input type="radio" value="L"></td> 
        <td>?<input type="radio" value="?"></td>
        <td>D<input type="radio" value="D"></td>


You could always use javascript to enable radio buttons in order. In that case, you render the radiobuttons disabled when the page is initially loaded. When a user clicks a radiobutton for question one, this triggers an event to enable the radiobuttons for question two etc. If you name your radiobuttons consistently, you could jQuery to do this efficiently e.g. if you give them names like "q_1", "q_2", ...

$("input[type=radio]").change(function() {
  var name = $(this).attr("name");
  var q = name.split("_");
  var next = "q_" + (parseInt(q[1]) + 1);
  $("input[name=" + next + "]").removeAttr("disabled");
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜