How to get the value of a field using javascript

Hi all I have a editable field in my form .It is a $$viewtemplate.

.The name of the field is “test” .The field has the forumula @getfield(“myfield”);The value is set in that field.

In the onload event of the form i have the following code

var q=document.forms[0].test.value

alert(q)

But i am getting the error as “document.forms.0.test.value is null or not an object.”

What should i do in order to get the value using javascript?

Should i neeed to specify the form name ,if so where should i specify the form name?

The form has a field “Form name” .It has a default value .When i try to tgive that value i am getting the same error .

Is it coz it is aviewtemplate so i am not getting the value when i use the docuemnt.form[0].test.value is not obtained

Does anyone has any idea?

Thanks in advance

paula j

Subject: how to get the value of a field using javascript

$$ViewTemplates are not opened in edit mode, and forms in read mode do not have HTML fields. You would need to create an HTML field in passthru HTML. Make the field computed for display instead of editable, and place it inside the following:

Mark the whole thing as passthru HTML (Text->Passthru HTML). That will make the value available to your JavaScript.

Subject: Thanks Mr.Stan Rogers .It works fine

Thanks Mr.Stan ,It works fine.Thank a lot

paula j

Subject: how to get the value of a field using javascript

OK, a quick solotion:There are several ways to solve this. One that I often use is to put script on the form itself.

…where the computed text contains the appropriate formula.

That way the variable q is available in your code.

I am aware I haven’t really answered your question… :slight_smile:

Morten Steinhauer

http://www.promasoft.no