T
|
thesofa 10/7/2008 |
I have a table setup with a Checkbox, and a Date/Time field (among others). What I'd like to happen is that as soon as the Checkbox is selected and the record saved, the Date/Time field is populated with the current Date/Time so as to keep a record as to when that record was "Completed". I know I have to set this up as as custom code, but I'm not entirely sure how it needs to be setup or where it should go. Any help will be appreciated.
If $values["checkbox"]; |
K
|
Khris author 10/7/2008 |
Since it's a checkbox, and the type is tinyint, the only options are 0 and 1. So how do I tell it that if the Checkbox = 1, then assign the date/time field to "now()"? |
T
|
thesofa 10/8/2008 |
just try the code, if checkbox is 0 then it will not run, // Parameters:
|
L
|
laonian 10/8/2008 |
You may want to try this code: |
K
|
Khris author 10/8/2008 |
Here's what I had to change it to. If ($values["completed"]=1) |
K
|
Khris author 10/8/2008 |
You may want to try this code: If ($values["Checkbox"]==1) $values["Date/Time"]=now(); My two cents.
|
L
|
laonian 10/8/2008 |
Thanks, I actually got it figured out and posted pretty much the same thing a minute after you. Does it make a difference to only use one equals sign instead of two?
|
T
|
thesofa 10/8/2008 |
Yes. it does. Single sign means you assign the value to it. Double means a condition. My two cents. If ($values["completed"]);
|
L
|
laonian 10/8/2008 |
If ($values["completed"]);
|
K
|
Khris author 10/8/2008 |
code If ($values["completed"]) //";" should be removed may work or may not work. If the "completed" field has been given a default value (e.g., 0) in the database, your code may cause a problem. code If ($values["completed"]==1) seems more secure to me.
|