Pumpedplop Posted January 6, 2023 Report Share Posted January 6, 2023 So attached is a picture of part of the site. What I'm trying to do is whenever there is a letter filled in, in the most bottom search field I would like to automatically press the search button. So it would look like an active search. The two other fields typically don't change so it wouldn't matter if it didn't happen when they were edited. Quote Link to comment Share on other sites More sharing options...
CoopperBackpack Posted January 6, 2023 Report Share Posted January 6, 2023 Hello @Pumpedplop, 1) Please test the following code in the Footer section of the Search page (disable the HTML editor before pasting): <script> document.addEventListener('DataPageReady', autoSearch); function autoSearch() { document.querySelector('#Value1_1').addEventListener('change', event => { document.querySelector('.cbSearchButton').click(); }) } </script> This code works on the so-called 'change' event. The user needs to fill in the field and to click somewhere outside the field. 2) If you want to simulate a click when the user type any character in a field you may test the code with the 'keyup' event to see the result. This approach can be inconvenient if the field is set to the basis input field. <script> document.addEventListener('DataPageReady', autoSearch); function autoSearch() { document.querySelector('#Value1_1').addEventListener('keyup', event => { document.querySelector('.cbSearchButton').click(); }) } </script> Quote Link to comment Share on other sites More sharing options...
Kronos Posted January 6, 2023 Report Share Posted January 6, 2023 Hi @Pumpedplop, This forum thread might also help: Quote Link to comment Share on other sites More sharing options...
Pumpedplop Posted February 1, 2023 Author Report Share Posted February 1, 2023 On 1/6/2023 at 5:30 PM, CoopperBackpack said: Hello @Pumpedplop, 1) Please test the following code in the Footer section of the Search page (disable the HTML editor before pasting): <script> document.addEventListener('DataPageReady', autoSearch); function autoSearch() { document.querySelector('#Value1_1').addEventListener('change', event => { document.querySelector('.cbSearchButton').click(); }) } </script> This code works on the so-called 'change' event. The user needs to fill in the field and to click somewhere outside the field. 2) If you want to simulate a click when the user type any character in a field you may test the code with the 'keyup' event to see the result. This approach can be inconvenient if the field is set to the basis input field. <script> document.addEventListener('DataPageReady', autoSearch); function autoSearch() { document.querySelector('#Value1_1').addEventListener('keyup', event => { document.querySelector('.cbSearchButton').click(); }) } </script> Which ever of the 2 I try I always get the same error, seen in the picture below. Quote Link to comment Share on other sites More sharing options...
CoopperBackpack Posted February 1, 2023 Report Share Posted February 1, 2023 Hello @Pumpedplop, It looks like the element (field ) you reference in the code is not correct. Which DataPage type do you use? Is it a Report DataPage? Is the screenshot of the Search page you shared in the first past still valid? Quote Link to comment Share on other sites More sharing options...
Pumpedplop Posted February 8, 2023 Author Report Share Posted February 8, 2023 Hello @CoopperBackpack, Its is indeed a report page a tabular report page to be more specific and the first picture in this thread is still valid. Its is displayed along side another datapage on one HTML page. But the code should run directly on the website and shouldn't be influenced by the main display page I think. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.