title: Readonly text input not appearing for single answer
body: <p>I have a jsfiddle <a href="http://jsfiddle.net/JWTQk/32/" rel="nofollow">here</a></p>
  
  <p>Please look at Question 2 in the jsfiddle table as that question contains only a single answer.</p>
  
  <p>In the jquery function what I have tried to do it state that if a question only
      contains 1 answer, then the text input under the Marks Per Answer
      column for that answer should be readonly and display the same value
      as the Total Marks Remaining for that question.</p>
  
  <p>Also if you look in the jsfiddle, it states that under Total Marks Remaining column for that single row, it displays the number 5, it should display number 0. As that number 5 in the readonly text input minus the original number for total marks Remaining (which was 5) means that the number under Total Marks Remaining should be 0 for that row.</p>
  
  <p>My question is that what do I need to include in the jquery function in the jsfiddle so that:</p>
  
  <ol>
  <li><p>if a question has a single answer, that text input is readonly</p></li>
  <li><p>displays the total marks number in the text input</p></li>
  <li><p>displays 0 under "Total Marks Remaining" for that row as it should
  of perform the calculation between the number in the read only text
  input and the original Total Marks Remaining number.</p></li>
  </ol>
  
  <p>Below is the code for the jquery function:</p>
  
  <p>Jquery:</p>
  
  <pre><code>    $(function () {
          //alert("here");         
          var questions = $('#markstbl td[class*="_ans"]').length - 1;
  
          //disable single entry
          for (var i = 0; i &lt;= questions; i++) {
              if ($("[class*=q" + i + "_mark]").length == 1) {
                  var t_marks = $("[class*=q" + i + "_ans]").html();
                  //alert(t_marks);
                  $("[class*=q" + i + "_mark]").val(t_marks)
                      .attr("disabled", "disabled");
                  //$("[class*=q"+i+"_mark]").attr("disabled","disabled");
              }
          }
  
          //find each question set and add listeners
          for (var i = 0; i &lt;= questions; i++) {
              $('input[class*="q' + i + '"]').keyup(function () {
                  var cl = $(this).attr('class').split(" ")[1]
                  var questionno = cl.substring(cl.indexOf('q') + 1, cl.indexOf('_'));
                  var tot_marks = $(".q" + questionno + "_ans_org").val();
                  //alert(tot_marks);
                  var ans_t = 0;
                  $("[class*=q" + questionno + "_mark]").each(function () {
                      var num = (isNaN(parseInt($(this).val()))) ? 0 : parseInt($(this).val());
                      ans_t += parseInt(num);
                  });
                  ans_t = tot_marks - ans_t;
                  //alert(ans_t);
                  //var fixedno = tot_marks;
                  var ans = (parseInt(ans_t) &lt; 0) ? tot_marks : ans_t;
                  $(".q" + questionno + "_ans").val(ans);
                  $(".q" + questionno + "_ans_text").html(ans);
              });
          }
      });​
  </code></pre>
  
  <p>Below is the dynamic HTML Table:</p>
  
  <p>HTML:</p>
  
  <pre><code>    &lt;table border='1' id='markstbl'&gt;
  &lt;thead&gt;
  &lt;tr&gt;
  &lt;th class='questionth'&gt;Question No.&lt;/th&gt;
  &lt;th class='questionth'&gt;Question&lt;/th&gt;
  &lt;th class='answerth'&gt;Answer&lt;/th&gt;
  &lt;th class='answermarksth'&gt;Marks per Answer&lt;/th&gt;
  &lt;th class='totalmarksth'&gt;Total Marks&lt;/th&gt;
  &lt;th class='emptyth'&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
  &lt;?php
  $row_span = array_count_values($searchQuestionId);
  $prev_ques = '';
  foreach($searchQuestionId as $key=&gt;$questionId){
  
  ?&gt;
  
  &lt;tr class="questiontd"&gt;
      &lt;?php
      if($questionId != $prev_ques){
      ?&gt;
      &lt;td class="questionnumtd" name="numQuestion" rowspan="&lt;?php echo$row_span[$questionId]?&gt;"&gt;&lt;?php echo$questionId?&gt; &lt;input type="hidden" name="q&lt;?php echo$questionId?&gt;_ans_org" class="q&lt;?php echo$questionId?&gt;_ans_org" value="&lt;?php echo$searchMarks[$key]?&gt;"&gt;&lt;input type="hidden" name="q&lt;?php echo$questionId?&gt;_ans" class="q&lt;?php echo$questionId?&gt;_ans" value="&lt;?php echo$searchMarks[$key]?&gt;"&gt;&lt;/td&gt;
      &lt;td class="questioncontenttd" rowspan="&lt;?php echo$row_span[$questionId]?&gt;"&gt;&lt;?php echo$searchQuestionContent[$key]?&gt; &lt;/td&gt;
      &lt;?php
      }
      ?&gt;
  &lt;td class="answertd" name="answers[]"&gt;&lt;?php echo$searchAnswer[$key]?&gt;&lt;/td&gt;
  &lt;td class="answermarkstd"&gt;
  &lt;input class="individualMarks q&lt;?php echo$questionId?&gt;_mark_0"  q_group="1" name="answerMarks[]" id="individualtext" type="text" /&gt;
  &lt;/td&gt;
  &lt;?php
      if($questionId != $prev_ques){
      ?&gt;
  &lt;td class="totalmarkstd" rowspan="&lt;?php echo$row_span[$questionId]?&gt;"&gt;&lt;?php echo$totalMarks[$key]?&gt;&lt;/td&gt;
  &lt;td class="noofmarkstd q&lt;?php echo$questionId?&gt;_ans_text"  q_group="1" rowspan="&lt;?php echo$row_span[$questionId]?&gt;"&gt;&lt;?php echo"&lt;strong&gt;Marks Remaining:&lt;br/&gt;".$searchMarks[$key]."&lt;/strong&gt;"?&gt;&lt;/td&gt;
  &lt;?php
      }
      ?&gt;
  &lt;/tr&gt;
  &lt;?php
  $prev_ques = $questionId;
  }
  ?&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>