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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:48:24+00:00 2026-06-14T01:48:24+00:00

i want to get value from one function to the another function. and i

  • 0

i want to get value from one function to the another function. and i want to pass the value to handler page. but in that i cant get the value to pass .. here i had given the code. please help me. for example assume that for radio=MR & fname=john.

function getdata()
{
   alert('hi');
   var radio = document.getElementsByName("radiobuttonlist1");
   for (var i = 0; i < radio.length; i++)
   {
    if (radio[i].checked)
    alert(radio[i].value);
   }

   var fname=document.getElementById("Firstnametxt").value;
   alert(fname);
}

here i want to get all those values to another function this is my another function.

function sendinfo()
{
getdata();

 $(document).ready(function(){     

   var url="Handler.ashx?radio="+radio+"&fname="+fname+""; "here i want the values from above function"

  alert(url);
    $.getJSON(url,function(json)
    {
        $.each(json,function(i,weed)
        {



        });

    });

});

}

thank you . help me

  • 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-14T01:48:25+00:00Added an answer on June 14, 2026 at 1:48 am

    You can do this two ways.

    Option 1

    You can define those variables outside of both functions like:

    var radio;
    var fname;
    getdata() {
        radio = document.getElementsByName("radiobuttonlist1");
        fname=document.getElementById("Firstnametxt").value;
        // VALUE UPDATED HERE
    }
    sendinfo() {
        // VARIABLE ACCESSIBLE HERE
    }
    

    And then whenever the values of those variables is updated it will be updated at the scope those variables were initially defined (outside those functions).

    The scope of a javascript variable is within the curly braces {} that variable is in and any curly braces within that set. Scope in javascript often refers to those curly braces {}. There are exceptions including the if statement in which you can define variables inside of and access outside (assuming the condition was true).

    Option 2

    Or you can pass those variables as parameters to the second function like: sendinfo(radio, fname);

    Passing values by returning them

    You can return the values as an object literal in your getdata() function like this:

    getdata() {
        return {
            radio : document.getElementsByName("radiobuttonlist1"),
            fname : document.getElementById("Firstnametxt").value
        }
    }
    

    Then do this:

    sendinfo() {
        var data = getdata();
    }
    

    And then access those variables like: data.radio and data.fname.

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

Sidebar

Related Questions

I'm beginner in MVC3, and I want to get a value from an another
I want to take a value from a query in one function and use
Hi i want to get changed text value from JQuery but i can't select
I want to get the value from an array thats in a while fetchrow..
In symfony 2 controllers, every time I want to get a value from post
I want to get the CreateDate value from xml file the xml file is
Using Access 2003 I want to get a table value from the two databases
Possible Duplicate: Return value from thread I want to get the free memory of
i bascially want to get the value of a variable from the codebehind to
I want to get values from a row with the largest certain value (in

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.