javier_fernande
Occasional Observer

Get an element from form template

Hi Everybody,

I've got this CHECKBOX

<CMS_INPUT_CHECKBOX name="cs_checkbox" useLanguages="no">

        <CMS_INCLUDE_CONTENT type="entries" table="FS_DATA.industries">

          <LABEL lang="*">#row.name</LABEL>

        </CMS_INCLUDE_CONTENT>

        <LANGINFOS>

          <LANGINFO lang="*" label="Industries"/>

        </LANGINFOS>

      </CMS_INPUT_CHECKBOX>

Now, I want to add a button to select all the options

<FS_BUTTON name="cs_selectAllButton" hidden="no" onClick="script:test_selectallboxes">

        <LANGINFOS>

          <LANGINFO lang="*" label="Select All" description="Select all options."/>

        </LANGINFOS>

      </FS_BUTTON>

My question is... how can I choose the cs_checkbox element from the script?

My idea is to implement something similar to this Select CMS_INPUT_CHECKBOX per script but when I try to use that code in the script I'm receiving an error.

Could you help me?

Thank you!!!

2 Replies
felix_reinhold
Returning Responder

Hello Javier,

you should take a look at the "PARAMS"-section in the FS_BUTTON documentation.

Just pass the field as param:

<FS_BUTTON name="cs_selectAllButton" hidden="no" onClick="script:test_selectallboxes">

        <LANGINFOS>

          <LANGINFO lang="*" label="Select All" description="Select all options."/>

        </LANGINFOS>

    <PARAMS>

          <PARAM name="checkboxField">#field.cs_checkbox</PARAM>

    </PARAMS>

</FS_BUTTON>

Now in your script you can access the FormField via the variable checkboxField.

By using checkboxField.set(Object value) you can set the value of the field (you don't need to do lock- or save-operations in your script!)

Best regards

Felix

Thank you so much! This is the correct answer to my (silly Smiley Sad ) problem.

0 Kudos