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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:54:44+00:00 2026-05-27T07:54:44+00:00

I need to pass two values to a javascript function from inside another javascript

  • 0

I need to pass two values to a javascript function from inside another javascript function as follows:

Something.innerHTML = Something.innerHTML + "<input type = 'submit' name = 'bbb' value = 'aaa' onclick = funcName(" + var1 + "," + var2 + "); />";

where: var1, var2 are two variables, whose values as shown by firebug are 2 and 3 respectively.

i) No error arises if I pass a single value, and the function receives a single value, i.e. funcName(var1)

ii) No error arises if I pass var1 twice, i.e. funcName(var1, var1);

iii) Error as reported by firebug when I pass var1, var2, i.e. funcName(var1, var2); is: missing ) after argument list and reports the following line: funcName(2,3

EDIT:
i) If I replace, ‘var1’, with any other variable, I am afraid the function does not work.

ii) I tried appending the two params using:

temp = var1 + “–” + var2;

And then ‘decoding’ it back in the receiving function, so that you could pass a ‘single’ parameter, but of no use.

  • 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-27T07:54:45+00:00Added an answer on May 27, 2026 at 7:54 am

    You didn’t put quotes around the attribute. Moreover you shouldn’t use spaces:

    onclick=\"funcName(" + var1 + "," + var2 + ");\"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have two forms where we need to pass values from one to the
I need to pass values from my asp.net code to a javascript code block
This question is regarding getopt function in php. I need to pass two parameter
I need to pass an array from JavaScript to a page method in C#.
Hi I'm using VBA in Excel and need to pass in the values from
I need to pull values in similar tables from two different databases, combine them
In array I do have two values value1=234.3423 value2=12.60348 i need to pass this
I want to pass two values from view to controller . i.e., @Model.idText and
I need to pass an object (my own business object) between two tables in
I need to pass multiple arguments to a function that I would like to

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.