How to make hidden fields temporary

Jake Howlett, 14 November 2000

Category: Forms; Keywords: hidden input 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.