{"id":2028,"date":"2024-03-19T14:47:15","date_gmt":"2024-03-19T14:47:15","guid":{"rendered":"http:\/\/dat.dk\/jupiterx-codes\/prefill-search\/"},"modified":"2024-03-19T14:47:15","modified_gmt":"2024-03-19T14:47:15","slug":"prefill-search","status":"publish","type":"jupiterx-codes","link":"https:\/\/dat.dk\/no\/jupiterx-codes\/prefill-search\/","title":{"rendered":"Prefill search"},"content":{"rendered":"<p><script>\n  document.addEventListener('DOMContentLoaded', function() {\n    \/\/ Function to get the value of a URL parameter by name\n    function getQueryParam(name) {\n      const urlSearchParams = new URLSearchParams(window.location.search);\n      return urlSearchParams.get(name);\n    }<\/p>\n<p>    \/\/ Get the search query parameter value\n    const searchQuery = getQueryParam('s');<\/p>\n<p>    \/\/ Check if the searchQuery exists\n    if (searchQuery) {\n      \/\/ Attempt to find the search input field in the container with id 'searchInput'\n      const container = document.getElementById('searchInput');\n      if (container) {\n        const inputField = container.querySelector('.raven-search-form-input');\n        if (inputField) {\n          \/\/ Set the value of the input field to the search query parameter\n          inputField.value = searchQuery;\n        } else {\n          console.error('Input field with class \"raven-search-form-input\" not found.');\n        }\n      } else {\n        console.error('Container with id \"searchInput\" not found.');\n      }\n    }\n  });\n<\/script><\/p>\n","protected":false},"author":2,"template":"","meta":{"_acf_changed":false,"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":""},"class_list":["post-2028","jupiterx-codes","type-jupiterx-codes","status-publish","hentry"],"acf":[],"_links":{"self":[{"href":"https:\/\/dat.dk\/no\/wp-json\/wp\/v2\/jupiterx-codes\/2028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dat.dk\/no\/wp-json\/wp\/v2\/jupiterx-codes"}],"about":[{"href":"https:\/\/dat.dk\/no\/wp-json\/wp\/v2\/types\/jupiterx-codes"}],"author":[{"embeddable":true,"href":"https:\/\/dat.dk\/no\/wp-json\/wp\/v2\/users\/2"}],"wp:attachment":[{"href":"https:\/\/dat.dk\/no\/wp-json\/wp\/v2\/media?parent=2028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}