There's probably a number of ways to do this, so here's just 1:
Since display, edit, and add are all basically the same data, here's what we usually
do (let's say for filling out a person's personal information for the Persons table in
your
database):
First, note the cfparam for "ATTRIBUTES.Person_ID". If a person_id was passed in,
then you know you'll be editing or showing. If not, it will be set to 0. Either way,
the query
will run. If Person_ID is not 0, then you'll get 1 record back through the query with
your desired data. If Person_ID is 0, your query will NOT barf, and you'll get back
no values
(which when displayed will be blank).
Then you test for the "action" attribute (which you pass in, depending on if you want
this particular user to view-only or to be able to add/edit.). If action is just
show, then
you'll see everything but without the input fields. If action is NOT show, then
you'll see the data with the input fields.
Somewhere else you'll want to determine the user's role and maybe set that as a
session variable or whatever. So then the call to this page might be something like:
<cfif session.CanEdit = 1>
<cfinclude thispage.cfm?action=edit>
<cfelse>
<cfinclude thispage.cfm?action=show>
</cfif>
Like I said, many ways to implement, but hopefully this'll give you an idea of where
you can head toward.
<cfparam name="ATTRIBUTES.Person_ID" default="0" type="numeric">
<cfquery name="getPersons" (etc)>
SELECT *
FROM Persons
WHERE Persons.Person_ID = #ATTRIBUTES.Person_ID#
</cfquery>
<cfif ATTRIBUTES.action EQ "show"> <cfoutput>
<table>
<tr>
<th valign="top">Last Name</th>
<td>#getPersons.P_LastName#</td>
</tr>
<tr>...(all other data) ...</tr>
<cfelse>
<cfform name="frmPersons" ACTION="#APPLICATION.self#?FuseAction=#ATTRIBUTES.RFA#"
method="post">
<cfoutput>
<input type="hidden" name="Person_ID" value="#ATTRIBUTES.Person_ID#">
<table>
<tr>
<th valign="top">Last Name</th>
<td>
<INPUT TYPE="TEXT" NAME="P_LastName"
VALUE="#getPersons.P_LastName#" SIZE="50" MAXLENGTH="50"></td>
</tr>
<tr>... all other data ... </tr>
[EMAIL PROTECTED] wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> I'm writing an app in cold fusion that has users who are in different
> roles and who may be viewing some data they dhouldn't edit or may be
> editing that data, depending on the role and situation.
>
> I'm trying to write it in such a way that I use on cfm page that
> has the option set in a flag whether to be read only.
>
> Right now it is a form with a onClick function used in each field
> that either does nothing or does a blur() and pops a message "you can't
> edit"(basically).
>
> I'd like to make it look better or at least different when it is in
> read-only mode - for instance have it not be a form field but just some
> text, or a form field of a different color (is that possible)?
>
> Any advice would be appreciated.
>
>
> John Holland
> - ---------------
>
> Email: [EMAIL PROTECTED]
> Web: http://jbhsoft.linuxave.net
> Public key : finger -s or
> http://jbhsoft.linuxave.net/pubkey.html
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP 6.5.2
>
> iQA/AwUBOOjq9xPWCCE2yAKHEQJgpgCZAZIBy2Y0NuBOtnT0oOUnl7AE3AoAoKpr
> eptMA0eZLx4kbhr/m/+Ofu1S
> =W9nl
> -----END PGP SIGNATURE-----
>
> ------------------------------------------------------------------------------
> Archives: http://www.eGroups.com/list/cf-talk
> To Unsubscribe visit
>http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
>message to [EMAIL PROTECTED] with 'unsubscribe' in the body.
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.