Click here to Skip to main content
11,704,315 members (42,813 online)
Rate this: bad
good
Please Sign up or sign in to vote.
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 17-Jan-13 17:58pm

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hi,
what i can suggest you to go by is the code like below:
suppose,we have this sort of design
<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-
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);
       }
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 740
1 OriginalGriff 520
2 Maciej Los 355
3 Andy Lanng 284
4 CPallini 275
0 OriginalGriff 8,824
1 Sergey Alexandrovich Kryukov 8,247
2 CPallini 5,197
3 Maciej Los 4,726
4 Mika Wendelius 3,606


Advertise | Privacy | Mobile
Web03 | 2.8.150819.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100