CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> Archive -> GotoCode Archive

 How to check if checkbox value was changed?

Print topic Send  topic

Author Message
Tomasz
Posted: 01/24/2002, 8:47 AM

I would like to store in db info bout changing the state of checkbox, (both check / unchecked).
This means that after changing checkbox value in record form, an action have to
be executed in before update event. If checkbox is left as it was, no action is
done

Anybody has an idea?

I think about storing present checkbox field value in variable in 'before show'
event, and then in 'before update' compare it with... with what?..

(kind of solution could be using 'after insert' event: sql query can look for
checkbox value in db after updating, and then comparing it with stored
variable.. but I'm lookin for much simple way)
Nicole
Posted: 01/25/2002, 4:52 AM

Tomasz,
to compare the old and new values of checkbox field use BeforeUpdate event. The new value is stored in fld+field_name variable, to get the old one use dLookUp function. E.g.:
old = dLookUp("table_name", "field_name", "primary_key_field=" & pPKprimary_key_field)
new = fldfield_name
Tomasz
Posted: 01/31/2002, 1:15 AM

Nicole,

I've tried this with no effect.
Table 'users', db field 'blocked', PK 'user_id', dlookup in open event:

$old_blocked = dlookup("users", "blocked", "user_id=".get_param("user_id"));

and in before update the following:

if ($fldblocked != $old_blocked)
{
$db->query("UPDATE timestamp SET users_blocked = NOW()");
}

and the result is: 'timestamp' table is updated with NO condition, every time.
Nicole
Posted: 01/31/2002, 4:21 AM

Tomasz,
I assume user_id field is added to record form. Is it primary key of the table used on this record form?
Tomasz
Posted: 01/31/2002, 5:42 AM

Nicole,

Yes, user_id is primary key for 'users' table and is added to record form
Nicole
Posted: 01/31/2002, 6:14 AM

Try to print the $old_blocked and $fldblocked variables in BeforeUpdate event and check their values.
Tomasz
Posted: 01/31/2002, 11:38 AM

Nicole,

Thank you for patience.
After hundreds of mouse clicks, I've found it: data type in checkbox properties was 'text'. After changing to 'number', it worked. And finally, dlookup is in 'before update' event.

   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.