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 7996159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:38:14+00:00 2026-06-04T14:38:14+00:00

I pass a number of parameter to a javascript function which builds a form

  • 0

I pass a number of parameter to a javascript function which builds a form for the user to fill in. Among these parameters are two more functions contained in a separate class which handle the saving or canceling of the form. The cancel function requires two parameters which it uses to determine which list of entities to build. The problem lies in the parameters. While in the form building function, if I attached the cancel function to the newly created cancel button without giving it any parameter the function button works fine but builds an empty list due to the lack of parameters. However if I attach the function with the parameters, the function fires right away when the page is created rather than when the button is clicked. I have tried attaching the listener in a couple different ways including javascript, jquery and even yahoo.util. Everything works correctly in the cancel function when it is called with parameters in other instances. Any ideas on why the function fires to early when parameters are passed?

Here is some sudo code of different ways I have attached the even listener.

function buildform(formData, saveFunction, CancelFunction, p1, p2){
      $("#cancelButton").live("click", cancelFunction(p1, p2);
      YAHOO.util.Event.on("cancelButton", "click", cancelFuntion(p1, p2));
      cancelButton.setAttribute("onClick",cancelFunction(p1, p2);
}
  • 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-06-04T14:38:16+00:00Added an answer on June 4, 2026 at 2:38 pm

    You have to wrap your method calls in function blocks, otherwise they are evaluated immediately:

    $("#cancelButton").live("click", function () { cancelFunction(p1, p2); });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to pass a varying number of parameters between two objects. I have
In my template-matching code I need the user to pass a floating-point parameter, which
I have defined a custom tag to take one parameter, a number, which it
I have a function that decrements a whole number parameter represented by a string.
Afternoon, I wish to pass the row number of a table to a function
I want to pass a parameter into my function. The parameter will be a
I am trying to pass a JavaScript function with an onclick event in php.
i have this jquery function that i want to pass topic parameter to, i
IMO python is pass by value if the parameter is basic types, like number,
Hello friends i am to add optional parameter to pass these in a method

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.