This topic is locked

Automatically add date after checkbox checked

1/11/2008 12:38:29 PM
PHPRunner General questions
E
ewold author

Hi, i was trying to figure out how to set a date field to today but only if a checkbox completed is checked in the edit or add record page. Inline editing and adding is disabled.
My table looks like date arrived, pieces, costs , and so on, but for reporting it would be handy if we had a total of the previous month of the records that are marked completed.

So when i check the box completed (TINYINT), he has to auto add the date to the column completed_date with the now() function.

I was also looking in the 4.2 beta version since you should now have field that can be auto filled in with last updated and date created and so on, but i didn't find it there also <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=7253&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />
Can anyone set me on track for this ?

Doesn't need te be AJAX , an after edit function should also do the trick.

When you save the record and the completed field is checked and the completed_date record is still empty (NULL) (we don't want it afterwards to be overwritten by an occasional edit) then set the date to today.
PS : PHPRunner just works great

J
Jane 1/14/2008

Hi,
you can set up completed_date value to now() in the Before record added or Before record updated events on the Events tab.

Here is a sample:

$values["completed_date"]= now();

E
ewold author 1/14/2008

Hi,

you can set up completed_date value to now() in the Before record added or Before record updated events on the Events tab.

Here is a sample:


Thx, that was not really the problem, the thing i want to do is to autofill this date after someone checked the completed chechbox and if the date not already has been filled in, when people edit it afterwards or something like that.

Mare with a After record updated In short words

If $values["Completed"]=1 and $values["Completed_Date"]=Null Then $values["completed_date"]= now();


But i can't get it to work, screwed up a number of times the whole site <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=24892&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' /> but nothing working yet. With an {if} function error page showing up.

J
Jane 1/15/2008

Hi,
try to use this code:

if ($values["Completed"]==1 && !$values["Completed_Date"])

$values["Completed_Date"]= now();

L
lbragg 1/28/2008

Jane-
Is there a way to do this in ASPRunner 5.2?

J
Jane 1/29/2008

Leo,
sure you can do it in the ASPRunnerPro.

Here is a sample code:

if dict("Completed")=1 and isnull(dict("Completed_Date")) then

dict("Completed_Date")= Now()

end if