jquery on keypress to calculate marks

jquery on keypress to calculate marks

Hello Guys..
I am new to jquery and I will be very grateful if you could help me.

have a look at my code to better understanding it

The javascript part

<script>
$(document).ready(function(){
    var a=0, 
        b=0;

    $(('input#a')[0]).bind('keyup', function(e){
        a = parseInt($(this).val()) || 0;
        var c = (a + b);

        $(('input#c')[0]).val(c);

    });  

    $(('input#b')[0]).bind('keyup', function(e){
        b = parseInt($(this).val()) || 0;
        var c = (a + b);

        $(('input#c')[0]).val(c);
    });

});


</script>

The html part and php part


$i = 1;
while($row_student = mysql_fetch_array($query_student)){

$student_id = $row_student['student_id'];
$exam_index = $row_student['exam_index'];
$surname = $row_student['surname'];
$othername = $row_student['othername'];
$title = $row_student['title'];

?>


<tr>
<td class="caption5a"><?php echo $exam_index; ?></td>
<td class="caption5a"><?php echo strtoupper($surname); ?></td>
<td class="caption5a"><?php echo $othername; ?></td>
<td class="caption5a"><?php echo $title; ?></td>
<td class="caption5a"><input type="text" size="3" maxlength="3" class="textForm" disabled="disable" name="c<?php echo $i;?>" id="c<?php echo $i;?>" value=""></td>
<td class="caption5a">hp</td>
<td class="caption5a"><input type="text" size="3" maxlength="3" class="textForm" disabled="disable" name="grade<?php echo $i;?>" id="grade<?php echo $i;?>" value=""></td>
<td class="caption5a"><input type="text" size="3" maxlength="3" tabindex="<?php $i; ?>" class="textForm" name="a<?php echo $i;?>" id="a<?php echo $i;?>" value=""></td>
<td class="caption5a"><input type="text" size="3" maxlength="3"  class="textForm" name="b<?php echo $i;?>" id="b<?php echo $i;?>" value=""></td>


<?php 

$i = $i + 1;

} ?>

It's a computerization of a marking system. I must calculate of mark of students.

I must input the mark of each student in text field a and b. The value of textfield a and b are added and displayed in text field c. This part is working correctly.

My problem is that when am using a loop, the id of text field a become a.$i where the value of $i is incremented inside the loop.
Thus, in the javascript, how should i call the name of Text field a.$i, b.$i??

Thank advance for your help.