You are viewing limited content. For full access, please sign in.

Question

Question

Javascript and Field Names

asked on November 28, 2014

I'm trying to work with Javascript in Laserfiche forms and would like to be able to reference fields by their actual names not by having to use #Field1, #Field2, etc.

I can't seem to find a workaround.

Thanks,

Rob

0 0

Answer

SELECTED ANSWER
replied on December 2, 2014 Show version history

We recommend to use variable name instead of field name for field name can be duplicated on a form. And the variable name is always unique and should be kept unchanged even you change the field name.

0 0

Replies

replied on November 30, 2014

It's not easy to get the field by field name, but you can use the field variable name to get the parent element first like following:

 $('[attr=variablename] input').change(function(){
    alert("value for a single line field is changed");
});

You want to use field name because it is more meaningful when read the script than use "Field1"?

0 0
replied on December 1, 2014

Thanks for the suggestion.  In my case I was using a drop-down list so I had to change "input" to "select" on line 1 of your code, but was able to make it work.

Yes I want to use the field name because it is more meaningful than Field1, Field2, etc.   I also worry that if I delete and recreate a field it will break any Javascript that I have built because the automatic names might change.

0 0
SELECTED ANSWER
replied on December 2, 2014 Show version history

We recommend to use variable name instead of field name for field name can be duplicated on a form. And the variable name is always unique and should be kept unchanged even you change the field name.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.