{"id":260,"date":"2026-01-23T04:58:17","date_gmt":"2026-01-23T04:58:17","guid":{"rendered":"https:\/\/www.kwwd.co.uk\/blog\/?p=260"},"modified":"2026-01-23T04:58:17","modified_gmt":"2026-01-23T04:58:17","slug":"find-an-element-in-a-querystring-with-javascipt","status":"publish","type":"post","link":"https:\/\/www.kwwd.co.uk\/blog\/find-an-element-in-a-querystring-with-javascipt\/","title":{"rendered":"Find An Element In A QueryString With JavaScipt"},"content":{"rendered":"<p>If you want to see if there&#8217;s a valid element in a querystring and then take an action you can use JavaScript to parse the website URL:<\/p>\n<pre><code class=\"language-html\">\r\n\/\/ 1. Get the query string from the current URL\r\nconst urlParams = new URLSearchParams(window.location.search);\r\n\r\n\/\/ 2. Check if the 'AddNew' parameter exists and equals '1'\r\nif (urlParams.get('AddNew') === '1') {\r\n    \/\/ 3. Find your form field by its ID and focus on it\r\n    const targetField = document.getElementById('your-field-id');\r\n    if (targetField) {\r\n        targetField.focus();\r\n    }\r\n}\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>If you want to see if there&#8217;s a valid element in a querystring and then take an action you can use JavaScript to parse the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[68,66,15,67],"class_list":["post-260","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-address","tag-forms","tag-javascript","tag-querystring"],"_links":{"self":[{"href":"https:\/\/www.kwwd.co.uk\/blog\/wp-json\/wp\/v2\/posts\/260","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kwwd.co.uk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kwwd.co.uk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kwwd.co.uk\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kwwd.co.uk\/blog\/wp-json\/wp\/v2\/comments?post=260"}],"version-history":[{"count":0,"href":"https:\/\/www.kwwd.co.uk\/blog\/wp-json\/wp\/v2\/posts\/260\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.kwwd.co.uk\/blog\/wp-json\/wp\/v2\/media?parent=260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kwwd.co.uk\/blog\/wp-json\/wp\/v2\/categories?post=260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kwwd.co.uk\/blog\/wp-json\/wp\/v2\/tags?post=260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}