Home > Domino Tips > Developer > JavaScript > Never Use Computed for Display Fields Again!
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

JAVASCRIPT

Never Use Computed for Display Fields Again!


Gautam Misra
01.07.2002
Rating: -3.50- (out of 5) Hall of fame tip of the month winner


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


You Can View User Feedback To This Tip

This tip disables any fields or buttons on your form.

Developers have always had this problem of having to use computed for display fields for their corresponding editable fields. Suppose I do not want to use author fields, my default access is "Editor" and want that certain people should not be able to change certain field values at a particular status in the workflow. At the same time I want the user to be able to enter data in some other fields and click on certain buttons only. In Notes I would use controlled access sections. On the web, we all know how controlled access sections look like! So we tend to use computed for display fields showing the value of the original editable field so that the user does not change any specific data. Instead, wouldn't it be nice if we could just DISABLE the editable fields or buttons on that particular status, so that information was for read-only purposes only. Well, try this:

Code

(1) In the <HTML> Tab of your field/button enter a 'Name' in the 
Name field. Let's sat 'TestName' (2) Use the folowing code: document.forms[0].TestName.disabled = true This will disable that element on the form. (3) To enable, you simply say: document.forms[0].TestName.disabled = false. This way you can disable/enable fields/buttons etc... on your form.

USER FEEDBACK TO THIS TIP

  • Further to this tip, which is very useful at times and certainly reduces development time/Fields....

    You can also just Compute the word "DISABLED" into the HTML Attributes of the field. This code can then made more flexible/powerful by the use of @Formulae.....

    Code: If you want a field to only be editable by users with the Admin Roles then you can do this...

    In the HTML attributes section of the field... @If(@IsMember("[Admin]"; @UserRoles); ""; "DISABLED")

    The disabled field I have found can be confusing to users as they see a field but do not understand why they can't edit it. So I compromised by using a stylesheet to highlight the fields which are DISABLED - you can compute the HTML attributes to contain the class name "cDisabled" and control the look fo the field - here is an example..

    @If(@IsMember("[Admin]"; @UserRoles); ""; "DISABLED class="cDisabled"")
    
    and in the HTMLHEAD (or as passthru on the form) you can add
    
    <style>
    .cDisabled{
    	border-width: 0px
    }
    </style>
    
    
    Full HTML Example
    
    <html>
    <head>
    	<title>DISABLED Demo</title>
    <style>
    .cDisabled{
    	border-width: 0px
    }
    </style>
    </head>
    
    <body>
    <form>
    Editable Field
    <br>
    <input type="Text" name="Field1" value="Edit Me">
    <br><br><br>
    DISABLED Field
    <br>
    <input type="Text" name="Field2" value="Disabled" DISABLED class="cDisabled">
    </form>
    </body>
    </html>
    

    The MAJOR drawback for this method is that the DISABLED Tag (and the style sheet for that matter) is not supported in Netscape4 (works in Netscape 6.1) and any user can bypass the security by just using the netscape 4 browser...
    —Mark Roden

  • This tip isn't bad at all. If the user tries to use an older version of Netscape, you can simply us the blur property once you check if a version of Netscape is less than 6.1—Yoofi Ocran

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
JavaScript
Trap JavaScript runtime errors in Domino Web apps
JavaScript workaround fixes Lotus Notes 8.x PostOpen event issue
Write HTML and JavaScript in Notes view rows and columns on the Web
JavaScript detects Web browser type and version in Notes/Domino 8.0.2
JavaScript creates a jump box on a Lotus Notes Web form
How to create dynamic JavaScript in Notes Domino without formulas
Trap an attachment path via the Domino file upload control field
Converting Lotus Notes views to XML documents using JavaScript
Prevent errors on iFramed pages with JavaScript
How to add keyboard functionality for Lotus Notes documents

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts