Click here to Skip to main content
15,885,767 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
i want to update marks of a particular student in particular subject out of eight subjects.

know my question is how to identify that the particular text box value has been changed after clicking submit button there by the updation task is forwarded to the update.php. please give me your valuable answer. thanks in advance.

NOTE: all the eight text boxes have similar id.
Posted

1 solution

hi,
what i can suggest you to go by is the code like below:
suppose,we have this sort of design
C#
<div id="testTextDiv">
                   <input type="text" value="" onclick="changedValue(this.value,1);"  />
                   <input type="text" value="" onclick="changedValue(this.value,2);" />
                   <input type="text" value="" onclick="changedValue(this.value,3);" />
                   <input type="text" value="" onclick="changedValue(this.value,4);" />
                   <input type="text" value="" onclick="changedValue(this.value,5);" />
                   <input type="text" value="" onclick="changedValue(this.value,6);" />
                   <input type="text" value="" onclick="changedValue(this.value,7);" />
                   <input type="text" value="" onclick="changedValue(this.value,8);" />
                   <input type="text" value="" onclick="changedValue(this.value,9);" />
                   <input type="hidden" value="" id="hdnField" />
                   <input type="button" value="Submit" onclick="CalculateValue('testTextDiv');" id="testText" />
               </div>


and script to get the old and latest values according to the textbox,we can proceed lik-
C#
function CalculateValue(obj) {
           var values = 0;
           var changedValue = 0;
           var changedIndex = 0;
           var objArray = "";

           if ($('#hdnField').length > 0) {
               objArray = $('#hdnField').val();
               var changedValue = (objArray.split('@'))[0];
               var changedIndex = (objArray.split('@'))[1];
               if (changedValue != '') {

                   $('div #' + obj + '> input:text').each(function (index) {
                       if (changedIndex - 1 == index) {
                           alert('the old value is : ' + changedValue + ' in the ' + changedIndex);
                           alert('the new value is : ' + $(this).val() + ' in the ' + changedIndex);
                       }
                       values = parseInt(values) + parseInt($(this).val());
                   });
               }
           }

           $('div #' + obj + '> input:text').each(function () { values = parseInt(values) + parseInt($(this).val()); });
           $('div #' + obj + '> input:text').last().val(values);
       }

       function changedValue(obj, obj1) {
           var newValue = parseInt(obj);
           $('#hdnField').val(obj + '@' + obj1);
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900