<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Append &amp;quot;checked&amp;quot; checkbox values to form textarea in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Append-quot-checked-quot-checkbox-values-to-form-textarea/m-p/1104151#M41941</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/13203"&gt;@tmcmillan99&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your function is correct and it should work for simple HTML form. But I assume you are trying to do this in a HubSpot form and for that, you need to use form callback functions.&amp;nbsp;This &lt;A href="https://developers.hubspot.com/docs/reference/cms/forms#embed-code-callbacks" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;doc&lt;/STRONG&gt;&lt;/A&gt; will help you with that. Here is also an example:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;
  hbspt.forms.create({
    portalId: '',
    formId: '',
    onFormReady: function ($form) {
        // Request Training
    function captureCheckboxValues() {
        const checkboxes = document.querySelectorAll('input[type="checkbox"]:checked');
        const checkedValues = [];
        checkboxes.forEach(checkbox =&amp;gt; {
        checkedValues.push(checkbox.value);
        });
        const textarea = document.getElementByClassName('hs-fieldtype-textarea');
        textarea.value = checkedValues.join('\n');
    }
    },
  });
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-sheets-root="1"&gt;I hope this will help you out. Please mark it as &lt;STRONG&gt;Solution Accepted and upvote&lt;/STRONG&gt; to help another Community member.&lt;BR /&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2025 07:37:22 GMT</pubDate>
    <dc:creator>GRajput</dc:creator>
    <dc:date>2025-02-05T07:37:22Z</dc:date>
    <item>
      <title>Append "checked" checkbox values to form textarea</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Append-quot-checked-quot-checkbox-values-to-form-textarea/m-p/1104018#M41935</link>
      <description>&lt;P&gt;I have a page that contains numerous checkboxes and a form. I am trying to append the values of the checkboxed that have been checked to the form's textarea. I have not been able to get it to work and do not know what I am missing. Here is my javascript&amp;amp;colon;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;
  // Request Training
function captureCheckboxValues() {
    const checkboxes = document.querySelectorAll('input[type="checkbox"]:checked');
    const checkedValues = [];
    checkboxes.forEach(checkbox =&amp;gt; {
        checkedValues.push(checkbox.value);
    });
    const textarea = document.getElementByClassName('hs-fieldtype-textarea');
    textarea.value = checkedValues.join('\n');
}
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do I have something wrong with my code? Or is there something special required due to it being Hubspot form? Any suggestions/recommendations would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Terry McMillan&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 22:14:51 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Append-quot-checked-quot-checkbox-values-to-form-textarea/m-p/1104018#M41935</guid>
      <dc:creator>tmcmillan99</dc:creator>
      <dc:date>2025-02-04T22:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Append "checked" checkbox values to form textarea</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Append-quot-checked-quot-checkbox-values-to-form-textarea/m-p/1104151#M41941</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/13203"&gt;@tmcmillan99&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your function is correct and it should work for simple HTML form. But I assume you are trying to do this in a HubSpot form and for that, you need to use form callback functions.&amp;nbsp;This &lt;A href="https://developers.hubspot.com/docs/reference/cms/forms#embed-code-callbacks" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;doc&lt;/STRONG&gt;&lt;/A&gt; will help you with that. Here is also an example:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;script&amp;gt;
  hbspt.forms.create({
    portalId: '',
    formId: '',
    onFormReady: function ($form) {
        // Request Training
    function captureCheckboxValues() {
        const checkboxes = document.querySelectorAll('input[type="checkbox"]:checked');
        const checkedValues = [];
        checkboxes.forEach(checkbox =&amp;gt; {
        checkedValues.push(checkbox.value);
        });
        const textarea = document.getElementByClassName('hs-fieldtype-textarea');
        textarea.value = checkedValues.join('\n');
    }
    },
  });
&amp;lt;/script&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-sheets-root="1"&gt;I hope this will help you out. Please mark it as &lt;STRONG&gt;Solution Accepted and upvote&lt;/STRONG&gt; to help another Community member.&lt;BR /&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 07:37:22 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Append-quot-checked-quot-checkbox-values-to-form-textarea/m-p/1104151#M41941</guid>
      <dc:creator>GRajput</dc:creator>
      <dc:date>2025-02-05T07:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: Append "checked" checkbox values to form textarea</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Append-quot-checked-quot-checkbox-values-to-form-textarea/m-p/1104329#M41949</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/346639"&gt;@GRajput&lt;/a&gt;&amp;nbsp;Awesome! Thanks for the additional information and clarification. Exactly what I needed. I had a feeling that I was missing something in regards to it being a Hubspot form.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 14:41:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Append-quot-checked-quot-checkbox-values-to-form-textarea/m-p/1104329#M41949</guid>
      <dc:creator>tmcmillan99</dc:creator>
      <dc:date>2025-02-05T14:41:43Z</dc:date>
    </item>
  </channel>
</rss>

