close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Two "Show If" on a field?

Thread began 12/16/2010 2:55 pm by Sally | Last modified 12/17/2010 10:57 am by Jason Byrnes | 2534 views | 7 replies |

Sally

Two "Show If" on a field?

What I have is a data grid of names and contact info. When you click on one it brings you to the detail page. If it's you, or the admin, I want the option to update the information. Otherwise, the info (minus the password) is only viewable.

My problem is in trying to get the password field to show on the detail page only if it is the user's detail info ("If Self") or for the admin ("Admin Priv"). I can do either one, but I'm having trouble doing both. Here's my code:

<% If (WA_Auth_RulePasses("Admin Priv")) Then ' Begin Show Region %>
<% If (WA_Auth_RulePasses("If Self")) Then ' Begin Show Region %>
<th>Password:</th>
<td><input type="text" class="WAATKTextField" name="txtpassword" id="txtpassword" value="<%=(rs_resident_detail.Fields.Item("txtpassword").Value)%>" /></td>
<% End If ' End Show Region %>
<% End If ' End Show Region %>

If I'm the admin, but it's not my record, it won't show the field. Would I be better off to just duplicate the password field and apply a Show If to each instance of it? If I do duplicate the field, will that cause problems when Update is selected to update the database?

Also, I need to do the same thing to the Update button - either duplicate it or figure out how to get two Show If to work on one instance. But what I'm wondering is, if it's not your record and you are not admin the fields still appear editable. You can update any changes so it doesn't really cause problems, but is there a way to make it so others wouldn't even have the option of trying to edit the fields?

Thank you for any help.

Sally

Sign in to reply to this post

Jason ByrnesWebAssist

you need to modify the show if to use a compound if statement with an OR clause.


the way you have the if statement right now, it will only try to evaluate the second if when the first if statement is true.

instead of:

if condition 1  then
if condition 2 then
do something
end if
end if



you need to have:

if condition 1 OR condition 2  then
do something
end if




where you want to show the information as read only if the 2 conditions are not met, you need to add an else statement as well:

if condition 1 OR condition 2  then
do something
else
do something else
end if






so using the code from your show if, it would look like:

<% If (WA_Auth_RulePasses("Admin Priv") OR WA_Auth_RulePasses("If Self")) Then ' Begin Show Region %>
<th>Password:</th>
<td><input type="text" class="WAATKTextField" name="txtpassword" id="txtpassword" value="<%=(rs_resident_detail.Fields.Item("txtpass word").Value)%>" /></td>
<% Else %>
<th>Password:</th>
<td><%=(rs_resident_detail.Fields.Item("txtpass word").Value)%></td>
<% End If ' End Show Region %>
Sign in to reply to this post

Sally

Thanks for your help, Jason.

I've implemented what you've said (and thanks for the explanation too) but it is only showing the password field as editable if it meets the "If Self" condition. I know the "Admin Priv" rule works because I'm the admin and it shows me the Group field (which is "Admin Priv") but it shows the password as a read only to me unless it's my record.

Here's my code (I have no idea why the gaps in "password" are showing up when previewing this reply. They are not in the code I've pasted):

<tr>
<% If (WA_Auth_RulePasses("Admin Priv") OR WA_Auth_RulePasses("If Self")) Then ' Begin Show Region %>
<th>Password:</th>
<td><input type="text" class="WAATKTextField" name="txtpassword" id="txtpassword" value="<%=(rs_resident_detail.Fields.Item("txtpassword").Value)%>" size="32"/></td>
<% Else %>
<th>Password:</th>
<td><%=(rs_resident_detail.Fields.Item("txtpassword").Value)%></td>
<% End If ' End Show Region %>
</tr>

Sign in to reply to this post

Jason ByrnesWebAssist

please send a copy of the actual page in a zip archive so i can see the entire page code in context.

Sign in to reply to this post

Sally

Here you go - thank you!

Attached Files
Residents_Detail.zip
Sign in to reply to this post

Jason ByrnesWebAssist

hmmm, no reason why that should not be working, perhaps try changing the if statement to

<% If ((WA_Auth_RulePasses("Admin Priv")) OR (WA_Auth_RulePasses("If Self"))) Then ' Begin Show Region %>





or you could use the if..else if.. else format:

<% If (WA_Auth_RulePasses("If Self")) Then ' Begin Show Region %>
<th>Password:</th>
<td><input type="text" class="WAATKTextField" name="txtpassword" id="txtpassword" value="<%=(rs_resident_detail.Fields.Item("txtpassword").Value)%>" size="32"/></td>
<% Else IF (WA_Auth_RulePasses("Admin Priv")) Then %>
<th>Password:</th>
<td><input type="text" class="WAATKTextField" name="txtpassword" id="txtpassword" value="<%=(rs_resident_detail.Fields.Item("txtpassword").Value)%>" size="32"/></td>
<% Else %>
<th>Password:</th>
<td><%=(rs_resident_detail.Fields.Item("txtpassword").Value)%></td>
<% End If ' End Show Region %>
Sign in to reply to this post

Sally

That didn't work but I figured out why - error on my part. My "Admin Priv" rule was looking to the Group field of the wrong recordset. It was looking to the recordset based on the row or record clicked instead of the session id of the user.

Thanks much for your help - I would not have gotten the Or and Else options without it.

Sign in to reply to this post

Jason ByrnesWebAssist

ahhh, ok, glad to hear it is working.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...