Click here to Skip to main content
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 18: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 OriginalGriff 230
1 PIEBALDconsult 150
2 DamithSL 125
3 BillWoodruff 108
4 Garth J Lancaster 90
0 OriginalGriff 5,790
1 DamithSL 4,601
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,195


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 18 Jan 2013
Copyright © CodeProject, 1999-2014
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