logo

How to make hidden fields temporary

When it comes to hiding fields on the web the method you use depends on what it is that you are trying to achieve.

If you just want to hide the field from the browser completely then you can simply select hide from "Web browsers", as below:

Image

This field is then available for any computation performed by the domino server, whilst it is invisible to the browser. This makes it unavailable to any JavaScript functions.

If the field is required in your JavaScript then the field needs to sent to the browser and "hidden" in the HTML. Here is an example of what that would look like in HTML:

<input name="HideMe" value="can-u-c-me?" type="hidden" />


The standard way of producing such a field is to add the following in to its HTML Attributes:

Image

There is, however, one drawback to using this method: it can only be achieved using an editable field, meaning that the field and its data will get saved with the document. If you are anything like me then the thought of this is making you cringe.

So, how can we make a field that is hidden in the HTML and not saved with the document?

One method would be to simply add the necessary HTML to the form and mark it as Pass-Thru HTML.

Image

However, domino does not like this. When the form gets submitted from the web it is expecting to find a field called "HideMe" on the form and returns an "Item Not Found Exception" error. So the field HAS to exist.

The obvious solution is to use Computed For Display (CFD) fields, which exist but don't get saved, and are therefore temporary. However, we can't set the HTML Attributes of these fields. What we need is a mix of the two solutions shown above.

The image below shows a CFD field placed within the HTML we saw earlier:

Image

This way the field exists, is temporary, can be computed to any value and is available to JavaScript routines. Eureka!

As an example, consider the field discussed in this document that stores the date format of the server. This is not required in the document itself and should be computed anyway as it can change from server to server. However, it is need in JavaScript so as to validate that users enter their dates in the correct format.


Feedback

  1. Does this include Rich-Text fields?

    Hello! Well, I tried several different ways but I can't seem to be able to do this. I need to have a Rich-Text field available to Javascript, but hidden to the user. It doesn't matter if the data is shown in the Source Code. I've tried "type=hidden" in several places, but it doesn't seem to work. Does this apply to Rich-Text fields? If not, is there another way?

    Any help would be appreciated!

    Thanks.

    BTW, great site Jake! ;)

    1. Re: Does this include Rich-Text fields?

      Hmmm, never quite worked out why people want to hide RTF fields...

      If I were to do it I would probably use hidden layers: [<span class="html">] <div id="hiddenRTF" style="visibility:hidden;"> RT field here </div> [</span>] This way the content is hidden yet still accessible through JS (I think!)

      This is of course off the top of my head and you may well need to play around...

      Jake -CodeStore

      • avatar
      • Gareth Wiseman
      • Tue 18 Nov 2003

      Re: Does this include Rich-Text fields?

      In addition to type="hidden" in the html attributes property, have you tried using style attributes.

      Try: style=\"display:none;\" in the html attributes property.

      Gaz.

  2. Hiding a button

    Is it possible to achieve the same functionality within a button (ie hidden from the user but visible to JavaScript) ? This may seem like a strange request but I have I have a hotspot which does lots of validation, opens a thank-you type dialog and then fires off the click() method of the button in question. The button then contains an @MailSend formula. This works fine in that it sends a mail without submitting the form but to get it to work, the button itself must obviously be visible to JavaScript but I would ideally like to hide it from users.

    PS This is a method I dreamt up to try & seamlessly 'mix' JavaScript & formula language. If anyone has any better solutions I would be glad to hear.

    Regards

      • avatar
      • Stan Rogers
      • Thu 14 Nov 2002

      Re: Hiding a button

      Sure -- just use CSS. style="visibility: hidden" will do nicely. That can be set on the HTML tab of the button.

  3. type=hidden doesn't work on listbox fields

    Tried using the type=hidden on an editable field and it works perfectly.

    When I try it on an editable listbox filed it doesn't work!

    Anything else I can try that will enable me to hide an editable lisbox field - javascript needs to be able to see it . . .

    Thanks

  4. Hiding fields from Domino

    There is one method of hiding fields from Domino that seems to work.

    When creating fields with pass-thru html like in the previous example:

    <input name="HideMe" value="can-u-c-me?" type="hidden" />

    ...Domino complains and returns an "Item Not Found Exception" error when the form is submitted...

    One way to get round this issue is to replace the 'name' attribute with an 'id' attribute:

    <input id="HideMe" value="can-u-c-me?" type="hidden" />

    This way, you can still do all the javascript processing you like and still send the form to Domino without it throwing up an exception or saving the fields!

    1. DUH!

      *hits himself over the head* Why didn't I think of that???

      Thanks much for the tip, Gareth!

  5. Similar method using DIV or SPAN

    I've used a DIV or SPAN block to the same effect in the past. Eg:

    [<DIV id="myfield">CFD field here<DIV>]

    When Domino returns the CFD value (as text) in the document it can be read by Javascript:

    var myvalue = document.all.myfield.innerTEXT;

    which seems to work fine for simple (text) values, but I've never used it for dates although I suspect it would work OK. I guess NN users will know what to do instead of using 'document.all' (I don't code for that platform).

    Jake, this site is so great! Although I am an "experienced" Notes (client) admin/coder (CLP in both) my Domino web skills are pitiful. This web site has enabled me to really get to grips with Domino's idiosyncracies, as well as getting a whole raft of ideas.

    Well done, mate!

    1. Re: Similar method using DIV or SPAN

      See what I mean about pitiful skills?

      I can't even get this feedback box to accept my example HTML!

      So I'll replace the less-than/greater-than signs with square brackets whilst I wait for someone to tell me how I should be inputting those:

      [DIV id="myfield"]CFD goes here[/DIV]

      God, I feel so stupid...

  6. Hidden Field Issue

    I recently read a post in the Notes discussion and an article on your site concerning the use of computed for display fields and setting their values to be hidden.

    The html was like this:

    <inputname="initiatorname" value="FIELD INITIATORNAME" type="hidden">

    I have a form which this seems to cause a 404 error when I have this type of information on it. The issue is, I guess, is that I have some fields that do some look ups so the page refreshes and for some reason when the refresh occurs I get the 404 page could not be found, the value of the hidden field was a simple @username type of formula. When the page initially loads everything is fine and the source shows the field as having computed correctly and is represent properly in the source html.

    Any idea why this might be occurring?

    As always your help is greatly appreciated.

      • avatar
      • Jake
      • Thu 29 Apr 2004

      Re: Hidden Field Issue

      Are you sure it's a 404? More likely is it's a 500 server error. If it is a 404 then look at the URL ans see if it seems iffy.

      Otherwise make sure your browser (I assume it's IE) is set to NOT display "friendly" errors. Advanced Options dialog.

      Read more: http://www.codestore.net/store.nsf/unid/DOMM-4R5LAT?OpenDocument

      Jake

  7. "" Appears In Fields Created This Way :(

    Hi, Jake!

    I really like your site! I'm having a problem, though.

    I'm trying this suggestion (it's COOL!), but when I create a document on the web, every field created this way contains the value "</font>" as its first data element (ex: "</font>23567").

    I've experimented with using plain old text fields, editable fields, computed fields, CFD fields, to no avail. I've even tried making the field visible (using "Text" instead of "Hidden" in the type attribute). The "</font>" still appears as the first field value. The "Generate HTML for all Fields" option never seems to work anywhere, and doesn't seem to help here either.

    The only way to prevent this from happening is to remove the Notes field from inside the HTML, but that defeats the purpose of what we're trying to do here.

    Do you know why this is happening? Please let me know any suggestions you may have on how to fix this.

    Thanks!

    Joe

      • avatar
      • Jake
      • Wed 21 Jul 2004

      Re: "" Appears In Fields Created This Way :

      Sounds like Domino misbehaving to me. Look at the source-code to see what is going on.

      It's probably that you need to make sure the field is the "default form font". Select the field and make sure it is Size 10 blank Default Sans Serif (the normal). Or mark is as PassThru.

      Glad you like the site.

      Jake

      Show the rest of this thread

    • avatar
    • Kurt
    • Wed 9 Feb 2005

    Worked Like A Charm for My Problem

    Jake,

    Once again a tip you provided on your web site helped me out with a code issue.

    I had two hidden (hide-when formula), computed-for-display, fields with values that used values from date fields. When the date field values changed, the values in the CFD fields should have changed as well.

    The first CFD field worked fine, but the second field acted as though it was still using the original date values, as though it was pulling the date values from the "server doc(?)." When I did a view source on the page, the first CFD field was available and had values. The second CFD field was not even referenced.

    I unhid the fields and wrapped them with the code you provided in this tip, and voila, both fields now function correctly.

    Thanks for making the time to create this web site and sharing your tips.

  8. Hidden fields on the web

    OK. thats cool. I wanted an editable field to be hidden from the web and should be accessible by javascript.

    when I use the same technique like <input name="test" value="here the notes field" type="hidden">, whats happening is the text "<input name is taken as the default value for the field..

    any comments on this?

    • avatar
    • Debasish Biswal
    • Tue 23 Nov 2010

    It is is very good dite .This slove so many problems

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:



Navigate other articles in the category "Forms"

« Previous Article Next Article »
Adding new items to list fields   Marking fields as required

About This Article

Author: Jake Howlett
Category: Forms
Keywords: hidden; input; temporary;

Options

Feedback
Print Friendly

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »