/    Sign up×
Community /Pin to ProfileBookmark

Issue with web based CRM system

Hi there,
Firstly, I am new here, thank you for your time reading this today
We have a customer management system for our repair store.
We have an issue whereby our new host doesn’t like the constant searches that come from our “live search” box that is on the customer profile
Here is the coding of which I believe is responsible for this live search

>

$(document).ready(function(){
> $(“input#autoinvsearchbox”).keyup(function(){
> if(this.value.length<3) {
> $(“div#autoinvsearch”).slideUp(200,function(){
> return false;
> });
> }else{
> var encodedinv = encodeURIComponent(this.value);
> $(‘div#autoinvsearch’).load(‘autosearch.php?func=inv&search=’+encodedinv).slideDown(200);
> }
> });
> });

Please could you help me change this so that it only works once the user stops typing?
I have managed it with another part of the coding for the customer name section using the following adaption

From this

>
> $(this).change(update).keyup(update).keydown(update);
>
> update.apply(this);
>
> });
>
> return this;

To this :

>
>

function debounce(callback, wait) {
> let timeout;
> return (…args) => {
> clearTimeout(timeout);
> timeout = setTimeout(function () { callback.apply(this, args); }, wait);
> };
> }

>

window.addEventListener(‘keyup’, debounce( () => {
> update.apply(this);
> // code you would like to run 1000ms after the keyup event has stopped firing
> // further keyup events reset the timer, as expected
> }, 1000))

>
>
>
> });
>
> return this;

I appreciate any suggestions or help received, thank you again- for your time

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogMar 06.2021 — Welcome to the forums. As far as your question, I'll leave you in the hands of the several fine JavaScript coders we have here. However, a little tip for posting questions here, your code samples will format better if you wrap them in ... tags, rather than using any of the formatting icons in the text entry window. You can even specify the language, in some cases improving how smart that formatting is, e.g. [code=javascript]...[/code].
Copy linkTweet thisAlerts:
@mathewrculverauthorMar 06.2021 — @NogDog#1628967

Thank you for your welcome. I will edit my post shortly to make it a lot easier to read, thank you for your advice.
Copy linkTweet thisAlerts:
@AbubakarGibsonFeb 15.2023 — Hi there! Welcome to the community! I'm glad you're reaching out for help. It sounds like you're running into some issues with your customer management system's live search feature.
Copy linkTweet thisAlerts:
@SempervivumFeb 15.2023 — @AbubakarGibson#1650677

No benefit in replying to a year old thread - closing.
Copy linkTweet thisAlerts:
@SempervivumFeb 15.2023 — {"locked":true}
×

Success!

Help @mathewrculver spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...