Klib7 Posted February 23 Report Share Posted February 23 I have a search criteria that needs the same data in both criteria fields in order to function properly, but I want to hide the second field and have it automatically enter whatever number the user inputs into Criteria1. I've tried a few older Javascript codes that I found on this forum but none of them have worked. Any assistance would be amazing! Quote Link to comment Share on other sites More sharing options...
CoopperBackpack Posted February 26 Report Share Posted February 26 Hello @Klib7, Do you need to apply this to 2 separate search fields or 1 search field with Criteria? It is important to reference the fields. For case 1 you can add this code in the Footer section of the Search page: <script> if (document.DataPageReadyHandler == undefined) { const DataPageReadyHandler = (e) => { if (e.detail.appKey != '[@cbAppKey]') { return } const fieldOne = document.querySelector('#Value1_1'); const fieldTwo = document.querySelector('#Value2_1'); fieldOne.addEventListener('change', function(){ fieldTwo.value = event.target.value; }) } document.addEventListener('DataPageReady', DataPageReadyHandler) document.DataPageReadyHandler = 'Enabled' } </script> For case 2: <script> if (document.DataPageReadyHandler == undefined) { const DataPageReadyHandler = (e) => { if (e.detail.appKey != '[@cbAppKey]') { return } const criterionOne = document.querySelector('#Value1_1'); const criterionTwo = document.querySelector('#Value1_2'); criterionOne.addEventListener('change', function(){ criterionTwo.value = event.target.value; }) } document.addEventListener('DataPageReady', DataPageReadyHandler) document.DataPageReadyHandler = 'Enabled' } </script> If the code doesn`t work, please provide a screenshot of the Search page as on the screenshots examples that I added in this post above. 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.