SurreyWebDesigner
asked on
javascript to check if the contents of a textbox has changed
Is there a way of telling whether the contents of a textbox has been changed when the user hits the submit button on a form?
I have a list of dates which the user can change - at present it updates my database with all of the data from all of the textboxes.
I only want it to update the data that has actually been changed.
I've tried doing this with ASP but it hasn't worked - so I'm wondering if I can do something clever with JavaScript that means the database only gets updated with data that has actually changed.
Any ideas?
Cheers
SWD
I have a list of dates which the user can change - at present it updates my database with all of the data from all of the textboxes.
I only want it to update the data that has actually been changed.
I've tried doing this with ASP but it hasn't worked - so I'm wondering if I can do something clever with JavaScript that means the database only gets updated with data that has actually changed.
Any ideas?
Cheers
SWD
u can also use the defaultValue property
if(document.getElementById ('txt').va lue == document.getElementById('t xt').defau ltValue)
alert("same");
if(document.getElementById
alert("same");
ASKER
so maybe i could incorporate one of these into a solution that i could use. i was thinking that perhaps i could do it so that when the value in the textbox now is different to the original value then the value of a hidden field gets changed. Then I update the database only with the values from the hidden fields.
Would this work?
I'm not sure on the syntax - could you point me in the right direction?
Cheers
SWD
Would this work?
I'm not sure on the syntax - could you point me in the right direction?
Cheers
SWD
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Excellent - that worked ... thanks!
Very quick response by the way - cheers!
Very quick response by the way - cheers!
u r welcome and thanks for the grade and the sweet compliments!
now value1 attribute will have the original value
so u can check it like
var temp = document.getElementById('t
if(document.getElementById
alert("same");