Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8914943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:51:18+00:00 2026-06-15T04:51:18+00:00

So the table should really look like this below when the user accesses the

  • 0

So the table should really look like this below when the user accesses the page:

Marks Per Answer                                             Total Marks    Marks Remaining
(blank text input)                                                 4              4
(blank text input)                                                 6              6
(disabled text input = 4 (same value as under Total Marks))        4              0

My question is that how can both steps above be solved by changing the jquery below:

$(function() {   
//alert("here");         
var questions = $('#markstbl td[class*="_ans"]').length;

//disable single entry
for (var i=0;i<=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('readonly',true);
//$("[class*=q"+i+"_mark]").attr('readonly',true);
}                    
}

//find each question set and add listeners
for (var i=0;i<=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 = ans_t;
var answerText='<strong>'+ans+'</strong>';
$(".q"+questionno+"_ans").val(ans);
$(".q"+questionno+"_ans_text").html(answerText);
});
}
});

Below is the dynamic HTML table:

<form id="Marks" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">


<table border='1' id='markstbl'>
<thead>
<tr>
<th class='questionth'>Question No.</th>
<th class='questionth'>Question</th>
<th class='answerth'>Answer</th>
<th class='answermarksth'>Marks per Answer</th>
<th class='totalmarksth'>Total Marks</th>
<th class='noofmarksth'>Marks Remaining</th>
</tr>
</thead>
<tbody>
<?php
$row_span = array_count_values($searchQuestionId);
$prev_ques = '';
foreach($searchQuestionId as $key=>$questionId){

?>

<tr class="questiontd">
    <?php
    if($questionId != $prev_ques){
    ?>
    <td class="questionnumtd" name="numQuestion" rowspan="<?php echo$row_span[$questionId]?>"><?php echo$questionId?> <input type="hidden" name="q<?php echo$questionId?>_ans_org" class="q<?php echo$questionId?>_ans_org" value="<?php echo$searchMarks[$key]?>"><input type="hidden" name="q<?php echo$questionId?>_ans" class="q<?php echo$questionId?>_ans" value="<?php echo$searchMarks[$key]?>"></td>
    <td class="questioncontenttd" rowspan="<?php echo$row_span[$questionId]?>"><?php echo$searchQuestionContent[$key]?> </td>
    <?php
    }
    ?>
<td class="answertd" name="answers[]"><?php echo$searchAnswer[$key]?></td>
<td class="answermarkstd">
<input class="individualMarks q<?php echo$questionId?>_mark_0"  q_group="1" name="answerMarks[]" id="individualtext" type="text" />
</td>
<?php
    if($questionId != $prev_ques){
    ?>
<td class="totalmarkstd" rowspan="<?php echo$row_span[$questionId]?>"><?php echo$totalMarks[$key]?></td>
<td class="noofmarkstd q<?php echo$questionId?>_ans_text"  q_group="1" rowspan="<?php echo$row_span[$questionId]?>"><?php echo"<strong>".$searchMarks[$key]."</strong>"?></td>
<?php
    }
    ?>
</tr>
<?php
$prev_ques = $questionId;
}
?>
</tbody>
</table>
</form>

At the moment in the jquery function I am trying to use the t_marks variable to display the value in the text input but nothing is displayed when I alert t_marks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T04:51:19+00:00Added an answer on June 15, 2026 at 4:51 am

    You can use readonly instead of disabled

    Change

    $("[class*=q"+i+"_mark]").val(t_marks).attr("disabled","disabled");
    

    To

    $("[class*=q"+i+"_mark]").val(t_marks).attr('readonly',true);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with records that look like this: CREATE TABLE sample (
I have to create one table using XSLT and CSS. The table should look
I have a table where I should count if an user has reached a
What benefits does WCF bring to the table and why should I use this
This would be an example of database table: PHP script should limit query result
I have a table which is full of arbitrarily formatted phone numbers, like this
I'm trying to create a page which looks somewhat like this: http://www.drmichaelbogdan.com/plastic-surgery/ (I'm referring
This should be really simple, but I can't figure it out. So: how do
I want to left join 2 tables. So all attributes of left table should
How to create new table which structure should be same as another table I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.