Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HI Friends,,
I have a simple HTML form with some 4-5 controls like name,address,city(dropdown)..etc. which is already filled or binded from the database to the form.. Its like a edit form.

Now when i click on the Submit or Update button it has to loop through all the control, if any controls previous value doesn't match with the current value then "Update" update it. Else display a message that "No changes have been done";

Any idea
Posted
Comments
Sergey Alexandrovich Kryukov 22-Aug-14 1:38am    
You already described some reasonable algorithm. What prevents you from doing exactly that?
—SA
PRAKASH_N 22-Aug-14 1:45am    
is there any way to loop through only with TextBoxes,CheckBoxes,Dropdowns,Radio buttons..

When you first populate the controls, store the original values in corresponding hidden fields. When the user hits submit button, use javascript or jquery to check the value in each control against its corresponding hidden field. Got it?
Refer: How to loop through all elements of a form jQuery[^]
 
Share this answer
 
Comments
PRAKASH_N 22-Aug-14 2:03am    
yeah i got... but form size will grow if i have more than 20 textboxes and dropdowns...
Hello ,
BAsically take two Hidden fields uxHiddPrevVal ,uxDetectChange.
On focus of textbox set the previous value of that textbox to that hidden field uxHiddPrevVal .Ob blur campare the values of the hidden field uxHiddPrevVal to the textbox,if unmatched sets the value of anotheir hidden field uxDetectChangeto 1.

Now for anotheir textbox set,on focus set the values to that hidden field to the previous value.If the user does not changes the value then the hidden field uxDetectChange is alreadys set to 1.
On Click Of Update Button Detect the Value of that hidden field.if hidden field is set to 1, then allow Update therwise display a message that "No changes have been Made"
Have You Got it.

Hope it helps you.
Happy Coding:-)
 
Share this answer
 
v2

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