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

  • Home
  • SEARCH
  • 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 7018207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:00:53+00:00 2026-05-27T23:00:53+00:00

I want that diffrent events to call the same function. I read other post,

  • 0

I want that diffrent events to call the same function. I read other post, from here, but I want use this function just in one page.

The situation is something like this:

I have approx. 80 listbox(select) in a form, and I feed them throught a plugin, jCombo (jQuery&jSON&php). First I relate each select listbox (.change()) to a hidden field, because I want to store index on table (update method is made with php). The problem is when I reopen same record for modify(same php file), jCombo change all <select lists> and reinitialize to 0. So my my event $("select#listbox").change({}); change, obviously, my hidden field value to 0.

Having this situation I find a simple solution (I start use jQuery&Ajax three days ago) to unrelate function from select lists and relete to $(“#AddButton”).onmouseup({…});.
So, I write for 80 hidden field:

if ($("select#listbox_n_").val() != 0) {
   $("#hidden_n_").val($("select#listbox_n_").attr('value'));
}

,where n=1…80.

But now I must repeat this for Update button so:

  1. there is other method to address a function by name?
  2. what is the best place (eg.procedure or something) to “store” function, because I want to execute them, only if it’s call.
  • 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-27T23:00:53+00:00Added an answer on May 27, 2026 at 11:00 pm

    I’m guessing what you’re trying to do is call one function from multiple events? If so, all you need to do is write your function and reference it in your events. And as for placing the function, just place it outside of your document.ready ($(function() {...});).

    Just to illustrate, here’s something I happened to be writing when I read this question. This checks the length of a textarea field, and returns it. This is just plain and simple HTML/jQuery.

    HTML:

    <label for="message">Message: </label>
    <textarea name="message" id="message" rows="5" cols="70"></textarea>
    

    jQuery:

    $(function() {
           $("#message").keyup(checkLength);
           $("#message").keydown(checkLength);
           });
    
    function checkLength() {
        var maxlength = 255;
        var charlength = $(this).val().length;
        var returnstring = (charlength + " of " + maxlength + " characters used.");
    }
    

    As you can see, the function checkLength() is called twice, on both the keyup and keydown events from the textarea. Note that, like I said above, they are placed OUTSIDE of the document.ready function. It then returns a string that contains how many characters have been added, compared to the maximum amount. Last, but not least, note that the function is called WITHOUT (). This means that it is just a reference to the function, and it will only be called when that specific event is fired.

    I hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to execute a php-script from php that will use different constants and
I want to write a function in Python that returns different fixed values based
I want to create a method sum that I can call on different types,
I've got an event-driven network server program. This program accepts connections from other processes
i'm having a hard time understanding custom events and I keep getting this same
Here is what i want to do. Normally we can call javascript functions on
I want to use one data source (e.g. an Array) for multiple Datagrids that
This is continuing on from a query that was solved previously via stackoverflow (
I want to create a view that has different displays according to the role
I want to create an overlay on top of Google Maps that displays different

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.