CodeCharge Studio
search Register Login  

Web Reporting

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

YesSoftware Forums -> Archive -> GotoCode Archive

 If statement help

Print topic Send  topic

Author Message
Brandy
Posted: 04/30/2003, 9:29 AM

I am working on a task management in asp.
I have gotten eveything to work based on the CCS example codes so far.

Now i want to add code that says this:

if status_id=3(closed) then add the current date to the date finished field.
Can anyone help me with the code on it?

Also, i have put the default value open in the status field. How can i change to where, when inserting new record that status is a read only field, but when updating/editing it can be modified.

That way a person can't accidently choose close for a request because then it would put a closed date in the date finished field when the request was not really done.

Am i making any sense here?

thanks for any help.
Brandy
Hamilton
Posted: 04/30/2003, 9:43 AM

Let's get you part of the way there and then you can explain what's left.

You asked: if status_id=3(closed) then add the current date to the date finished field. Can anyone help me with the code on it?

On the record, place a hidden field called "date_finished"
Bind it to the date_finished field in the database.
If you already have a field called "date_finished" - change it to a hidden field.
Next,
Place your cursor so that it's somewhere on the record and from the 'events' tab select the "BeforeInsert" event... 'add code'

It should look something like this when you're through.

Function BeforeInsert()
'// get the value of the picklist called 'status'
Dim vResult : vResult = formpage.status_id.value
'//check for mode
If formpage.editmode then
'//record is being updated
If vResult = 3 then formpage.date_finished.value = FormatDateTime(now(), vbShortDate)
Else
'//record is being added
'//do nothing.
End If

End Function

Regarding you question:
How can i change to where, when inserting new record that status is a read only field, but when updating/editing it can be modified.

This may sound kind of strange, but you may need to do this in order to NOT mess around too much with the common.asp, template.asp, etc. files.

You're much better off having two pages to handle this due to your desire to have the read only toggle effect.

have one page called 'add_formname.asp' and another called 'upd_formname.asp'
One has the read only field and the other the editable field/selectable picklist.
Brandy
Posted: 04/30/2003, 10:16 AM

I added the code, i don't get any errors, but it doesn't put in the finishdate either.

what if i put the code on the submit button. so that the value of status id will already be defined as 3. Then the finishdate should just be added.

   


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

PHP Reports

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

Home   |    Search   |    Members   |    Register   |    Login


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