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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:45:18+00:00 2026-06-16T09:45:18+00:00

I am having two functions in my JavaScript code, and I want to perform

  • 0

I am having two functions in my JavaScript code, and I want to perform some action on the basis of value returned by other function.

Here my code :-

function test1(){
    var radio = document.getElementByName('sample');
    for (i=0; i<radio.length; i++){
         //some code here
         return "some value on basis of above code"
    }
}

function test2(){
    var somevariable = globllysetValue;
    var returnValue = return test1();
    // some code and work according to the value in returnValue
}

Well I know return in function test2 is not correct. so what can I do here NOW????


Edit

Here what I am Trying to do… but it do not seem to be working
http://jsfiddle.net/U6RjY/7/

EDIT2 —– The corrected and working fiddle… http://jsfiddle.net/U6RjY/9/
Thanks to all 🙂

  • 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-16T09:45:19+00:00Added an answer on June 16, 2026 at 9:45 am
    function test1(){
        var radio = document.getElementByName('sample');
         for (i=0; i<radio.length; i++){
             //some code here
             return "some value on basis of above code"
        }
    }
    
    function test2(){
        var somevariable = globllysetValue;
        var returnValue = test1();
        // some code and work according to the value in returnValue
    }
    

    Just remove the return.

    You will notice however that in function test1, it will return the value on the first loop. So, it will stop executing.

    Live example: http://jsfiddle.net/U6RjY/

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

Sidebar

Related Questions

I having two arrays say, $array1 = array(code => E0089, desc => some description);
I am having some problems with a javascipt function which I'm working on. Here
I'm new to JavaScript, and am having a problem understanding this code: function addProperty(o)
I'm having some slight problems with fading one div into another, here's my code
In JavaScript function, I want to concatenate a numbers. Text Box value format `1.234.567,89`
My layout having two parts. I want to change the upper part by keeping
I'm having two jquery's that I run and I want to combine them both
I have two different versions of a javascript file: one works fine, the other
I'm having some issues with a jQuery AJAX call. My code works fine when
Im having problems passing PHP Strings to Javascript functions, I'v read a number of

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.