need to know if data in form field has been changed

Shawn
Shawn used Ask the Experts™
on
I have a form that shows our clients their reference/purchase order.

I want to know if the purchase order has been changed before I update the field. How is this possible?

here is my field...
Your Purchase Order/Reference:
<input class=formcell type="text" name="fClientReference" value="#getMemberFiles.ClientReference#" size="30">
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2015

Commented:
Can you elaborate a bit more on "changed" and "updated"? Are you talking client side, database, etc..?

Author

Commented:
when a client modifies the form he/she may or may not modidy the field fClientReference. I need to know if this has been changed...

eg on form
Your Purchase Order/Reference: (empty)
scenario1: client adds "purchase101" - need to know this
scenario2: client doesn't touch this field
eg 2
Your Purchase Order/Reference: purchase101
scenario3: client leaves as is "purchase101"
scenario2: client changed it to "purchase102" - need to know this

is that clearer?
Most Valuable Expert 2015
Commented:
Yes, but I am not sure where you're doing the comparison in javascript or on the server side. You could always store the original value in a hidden form field.  Then compare the values of the two fields. Whether that's sufficient for your purposes depends on how secure the check needs to be.

But if the user shouldn't change the value, why make a text box? ;-)  I'm assuming there's a good reason for this.
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference through the Colors of STEM program.

Author

Commented:
the user is allowed to change this value. we just need to know when this happens.

I'd prefer if it were server side so storing in a hidden form field should work.
Most Valuable Expert 2015

Commented:
> I'd prefer if it were server side so storing in a hidden form field should work.

Well, obviously anything dependent on user values isn't super secure.  But, yes that would work.   Another option is running a db query to get the original value.  Though, that assumes no other query has updated the value in the mean time.

I'm not sure what you need to do if it has changed. In some cases a db trigger is useful.  You create a trigger that runs after any update and performs some action if the value has changed (like logging to another table).  I'm not saying that's what you need to do here, it's just an option to keep in mind.

Author

Commented:
I'm going to have an email sent to the Project Manager saying that the Purchase order was changed by client and to please verify

I like the idea of runny the query to compare...will take a shot at it and get back in a sec

Author

Commented:
think I got it....
in the display pagee. client ref pulled from the query
<input type="Hidden" name="fClientReferenceOriginal" value="#getMemberFiles.ClientReference#">

on action page
<cfif form.fClientReferenceOriginal NEQ form.fClientReference>
changed
<cfelse>
not changed
</cfif>

Author

Commented:
thanks agx

Author

Commented:
sorry, one last thing. when you mention not very secure. what do you mean?
Most Valuable Expert 2015

Commented:
The usual, that user supplied values can't be trusted.  Say you generate a form with values from you db.  Any semi-savy user could create a fake form and post it to your server and submit whatever form values they wanted to.  So the usual rules apply, if it needs to be secure never trust form values alone. Validate it against something users can't directly access like your db.

Author

Commented:
wow, that probably explains why I had this old form for referrals and deleted it because I was getting too much spam via the form...the thing is I'm still getting the emails that look like they came from the form.

that make sense? if it does maybe I should open another question on how to prevent this.
Most Valuable Expert 2015

Commented:
Oh yes, spam and the multitude of ways to avoid faked form posts, captcha, etc... is a whole 'nother topic altogether ;-)  
Most Valuable Expert 2015

Commented:
Plus, I'm getting ready to head out for the w/e (yaay!)

Author

Commented:
me too. thanks again...and I'll probably ask a question or 2 on that after a little more research

have a great w/e

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial