<?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: Delete button and refresh content to zero on background in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Delete-button-and-refresh-content-to-zero-on-background/m-p/813481#M34803</link>
    <description>&lt;P&gt;Thank you so much. It's work now.&lt;/P&gt;</description>
    <pubDate>Thu, 29 Jun 2023 08:23:08 GMT</pubDate>
    <dc:creator>EDemirgil</dc:creator>
    <dc:date>2023-06-29T08:23:08Z</dc:date>
    <item>
      <title>Delete button and refresh content to zero on background</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Delete-button-and-refresh-content-to-zero-on-background/m-p/812735#M34778</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;i would like to add 'clear' or 'X' button in the searchbar on my website. But this button should clear the form to zero like not used before. At this moment i delete the input text with backspace on keybord. When deleting finished filter content return to zero. Before opening this post i've added some codes with html and javascript but it doesn't work correctly, input text can be deleted but filtering can't reset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the my code on codepen:&amp;nbsp;&lt;A href="https://codepen.io/eyupdmg/pen/LYXWVrM" target="_blank"&gt;https://codepen.io/eyupdmg/pen/LYXWVrM&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and this is the website:&amp;nbsp;&lt;A href="https://www.broodjes-lemano.be/" target="_blank"&gt;https://www.broodjes-lemano.be/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2023 20:24:00 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Delete-button-and-refresh-content-to-zero-on-background/m-p/812735#M34778</guid>
      <dc:creator>EDemirgil</dc:creator>
      <dc:date>2023-06-27T20:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: Delete button and refresh content to zero on background</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Delete-button-and-refresh-content-to-zero-on-background/m-p/812985#M34789</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/590190"&gt;@EDemirgil&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure about it but you can try this.&lt;/P&gt;
&lt;P&gt;To add a clear button to your search bar that resets the form to its initial state, you can modify your existing code with some JavaScript logic. Here's an updated version of your code that achieves this functionality:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;HTML:&lt;/STRONG&gt;&lt;BR /&gt;```html&lt;BR /&gt;&amp;lt;div class="searchbar"&amp;gt;&lt;BR /&gt;&amp;lt;input type="text" id="searchInput" placeholder="Search..." /&amp;gt;&lt;BR /&gt;&amp;lt;button id="clearButton" onclick="clearSearch()"&amp;gt;X&amp;lt;/button&amp;gt;&lt;BR /&gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Javascript&amp;amp;colon;&lt;/STRONG&gt;&lt;BR /&gt;```javascript&lt;BR /&gt;function clearSearch() {&lt;BR /&gt;var input = document.getElementById("searchInput");&lt;BR /&gt;input.value = ""; // Clear the input text&lt;/P&gt;
&lt;P&gt;// Call the filter function to reset the content to its initial state&lt;BR /&gt;filterItems("");&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;function filterItems(searchTerm) {&lt;BR /&gt;var items = document.getElementsByClassName("product-item");&lt;/P&gt;
&lt;P&gt;for (var i = 0; i &amp;lt; items.length; i++) {&lt;BR /&gt;var item = items[i];&lt;BR /&gt;var itemName = item.getAttribute("data-name").toLowerCase();&lt;/P&gt;
&lt;P&gt;if (itemName.includes(searchTerm.toLowerCase())) {&lt;BR /&gt;item.style.display = "block"; // Display the item&lt;BR /&gt;} else {&lt;BR /&gt;item.style.display = "none"; // Hide the item&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;// Initialize the search functionality&lt;BR /&gt;var searchInput = document.getElementById("searchInput");&lt;BR /&gt;searchInput.addEventListener("input", function() {&lt;BR /&gt;filterItems(this.value);&lt;BR /&gt;});&lt;BR /&gt;```&lt;/P&gt;
&lt;P&gt;With these modifications, clicking on the clear button (X) will clear the search input and call the `filterItems` function with an empty string, effectively resetting the content to its initial state.&lt;/P&gt;
&lt;P&gt;Please note that you may need to adjust the styling and positioning of the clear button to match your design requirements.&lt;/P&gt;
&lt;P&gt;You can replace your existing code with the updated HTML and JavaScript code provided above to achieve the desired functionality.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this will helps you out. Please mark it as &lt;STRONG&gt;Solution Accepted&lt;/STRONG&gt; to help other Community member. Thanks!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 11:39:55 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Delete-button-and-refresh-content-to-zero-on-background/m-p/812985#M34789</guid>
      <dc:creator>GRajput</dc:creator>
      <dc:date>2023-06-28T11:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Delete button and refresh content to zero on background</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Delete-button-and-refresh-content-to-zero-on-background/m-p/813481#M34803</link>
      <description>&lt;P&gt;Thank you so much. It's work now.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Jun 2023 08:23:08 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Delete-button-and-refresh-content-to-zero-on-background/m-p/813481#M34803</guid>
      <dc:creator>EDemirgil</dc:creator>
      <dc:date>2023-06-29T08:23:08Z</dc:date>
    </item>
  </channel>
</rss>

