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
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
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.
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"?
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.
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.