Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7035513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:18:47+00:00 2026-05-28T01:18:47+00:00

I have a javascript library which does returns a list of results to a

  • 0

I have a javascript library which does returns a list of results to a div triggered on keyup events. I want to use Jquery to apply a standard keyup event to all fields on all pages which have a certain class.
That part I can do and it works OK.
My issue is that the parameters which I use are dynamic and the last 2 of these are optional functions.

<input type="text" 
class="font8_input" name="wsFromPart" 
value="<%=wsFromPart%>" id="wsFromPart" 
size="20" maxlength="20" 
onfocus="javascript:fncAjaxClear()" 
onkeyup="javascript:fncAjaxSearch('wsDatabase','..\\AjaxBrowses\\PartBrowse.asp','wsFromPart','wsFromPartList','fncPrePartAjax',null);"/>

At present, to control this I pass null if I don’t have a function.

I’m trying to get the to a position where I can define all of the fields like this.

<input type="text" class="PartClass" name="wsFromPart" value="<%=wsFromPart%>" id="wsFromPart" />

Everything else will be added by setting classes/events by Jquery.

I’m trying to work out how I can test if a function exists on my page, and only execute if it does. I’ve tried passing the function name as a string but can’t seem to make that work. My last attempt is to have a generic function, and pass the name of the function which may exist to this function to evaluate and, if a function, execute it.

<input type="text" class="font8_input" name="wsFrPt" id="wsFrPt" size="20" maxlength="20" value="<%=wsFrPt%>"  onfocus="javascript:fncAjaxClear()" onkeyup="javascript:fncAjaxSearch('wsDatabase','..\\AjaxBrowses\\PartBrowse.asp','wsFrPt','wsFrPtList',fncCheckFunction('fncPreAjaxPart1'),'fncPostAjaxPart');"/>


function fncAjaxSearch(wsDb,wsAsp,wsId,wsTarget,wsPreFunction,wsReturnFunction) {
var myDate = new Date();
var myDate1 = myDate.getTime();
if (objXHR.readyState == 4 || objXHR.readyState == 0) {
    var wsDatabase = escape(document.getElementById(wsDb).value);
    var wsStr = escape(document.getElementById(wsId).value);
    var wsParam = "";
    if (wsPreFunction !== null) {
        wsParam = wsPreFunction();
    }
//Only do ajax call if the 'source' field is not empty, otherwise empty target and clear border.
        if (document.getElementById(wsId).value > '') {
        objXHR.open("GET", wsAsp + '?qryDatabase=' + wsDatabase + '&qryDummy=' + myDate1 + '&qrySearch=' + wsStr + wsParam, true);
        objXHR.onreadystatechange = function(){if(objXHR.readyState==4){fncAjaxSearchReturn(objXHR,wsId,wsTarget,wsReturnFunction)}};
        objXHR.send(null);
    }
    else {
        document.getElementById(wsTarget).innerHTML = '';
        document.getElementById(wsTarget).style.borderWidth = '0px';
    }
}       

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:18:47+00:00Added an answer on May 28, 2026 at 1:18 am

    If it is a global, you can do this

    var fnc = window["yourFunctionName"];  //Use bracket notation to get a reference
    if( fnc && typeof fnc === "function" ) {  //make sure it exists and it is a function
        fnc();  //execute it
    }
    

    If it is namespaced, you can do the same type of thing, just involves some looping.

    var myFnc = "foo.bar.fun";
    var nameParts = myFnc.split(".");  //split up the string into the different levels
    var fnc = window;  //set it to window
    for(var i=0;i<nameParts.length;i++){  //loop through each level of the namespace
        fnc = fnc[nameParts[i]];
        if(!fnc){  //make sure it exists, if not exit loop
            fnc = null;
            break;
        }
    }
    if( fnc && typeof fnc === "function" ) {  //make sure it exists and it is a function
        fnc();  //execute it
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have a library or JavaScript snippet to validate the check digit of
I'm working on a Javascript library which is currently in use by our websites
I have a Magento site, which includes the prototype JavaScript library. Some time ago,
1) Which JavaScript hashchange/history library/method should I use for my JavaScript application? 2) And
I have a .tag file that requires a JavaScript library (as in a .js
I have JavaScript code which copies the value of input file and paste it
I've been writing some jQuery functions that have JavaScript variables and looping, etc inside
Does anyone have any experience in load testing ajax applications? specifically running jQuery as
Iam using one Jquery Library which takes the Regular expression in json format in
I have created an xPages application which uses a lot of server side javascript

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.