Return value of a computed field in javascript

Hi,

Does anybody knows how to write a java script code to get the value of a computed field in a notes form, I’m using the function below but is not working for me I’m getting an undefined value and the computes field does have a value.

thanks

Subject: java script code to get the value of a computed field in a notes form

Hi,

Make sure the form property “Generate HTML For All Fields” is checked.

Rgds,

Paras

Subject: RE: java script code to get the value of a computed field in a notes form

Hi,

I’m doing this in the JSHeader event, so the field get validated in web.

Subject: RE: java script code to get the value of a computed field in a notes form

And how does that effect Paras’s answer to you?

Subject: RE: java script code to get the value of a computed field in a notes form

Hi, Thanks for your answer, I’m just doing a research to find out how can I return the value of a computed field using java script.

Subject: Did you do what Paras suggested

and then look at the source of the page?

Subject: RE: java script code to get the value of a computed field in a notes form

There are two problems here. One is that computed fields are not rendered as fields/form elements by default on the web. Only their contents (when the field is not hidden) are rendered as text. That leaves you with three choices:

  1. Turn on “Generate HTML for all fields” for the form. This will generate HTML form elements of type=“hidden” for all computed and hidden fields, making them accessible to JavaScript.

PROBLEM: it generates HTML form elements for ALL fields, and on the web (unlike in the Notes environment) hiding a field is actually secure – you may not want that information leaking out into the world.

  1. Use computed text and passthru HTML to create HTML fields selectively for the data you want to use.

PROBLEMS: You may want to USE the field content, but you still may not want it available to your end users to read or modify, and in the case of computed fields, you now have user-submitted data that may be in conflict with your computation.

  1. Create “computed JavaScript” in Formula Language to insert values directly as JS variables. This avoids extra submitted fields, but may still “leak” data you want to keep secret, and it’s still changeable by the end user (the ability to modify any element of the page is built into most current browsers).

That’s the first set of problems. The other thing is that computed data doesn’t need to be validated. It is either correct based on the LAST values submitted (and, thus, potentially invalid based on the CURRENT data on the web page) or has not been computed yet at all (since the user data has not been submitted). Remember that computed fields (and computed text) are computed on the server, not in the web browser. It’s out of the user’s control. It is fair to USE computed data in order to validate editable information (although there are better ways to restrict user inputs than validation in that case), but it is not fair to make the user responsible for the result of a computation over which they have no immediate control.