Jump to content

Active search


Recommended Posts

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.

Capture.PNG

Link to comment
Share on other sites

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>

 

Link to comment
Share on other sites

  • 4 weeks later...
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.

10220231358.PNG

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...