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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:20:43+00:00 2026-05-29T07:20:43+00:00

this is most probably simple but im struggling a little is it possible to

  • 0

this is most probably simple but im struggling a little is it possible to do something like the below becasue its not alerting in the 2nd function.

function func1() {
  var test = 5;
  var testAgain = 8;
}


function func3() {
  func1();
  alert(test);
}

edit:

Thank you all for your comments, however i cant seem to get it to work.

i below is the code i am trying to get this to work in

it does not seem to want to pass the vars from setImageReelWidth, and just alerts 0 when it gets to rotate = function () or $(“.paging a”).click(function (). so i click and it alerts 4 (which is correct) and then when it runs it twice again i just get 0

var divWidth = 0;
var slideTotal = 0;
var divReelWidth = 0;


function setImageReelWidth() {
    var divWidth = $(".window").width();
    var slideTotal = $(".slide").size();
    var divReelWidth = divWidth * slideTotal;
    alert(slideTotal);
    //Adjust the image reel to its new size
    $(".image_reel").css({ 'width': divReelWidth });
}





$(document).ready(function () {
    ////////////////////////////  INITAL SET UP  /////////////////////////////////////////////

    //Get size of images, how many there are, then determin the size of the image reel.
    //var divWidth = $(".window").width();
    //var slideTotal = $(".slide").size();
    //var divReelWidth = divWidth * slideTotal;

    //Adjust the image reel to its new size
    //$(".image_reel").css({ 'width': divReelWidth });

    //set the initial not active state
    $('#prev').attr("class", "not_active");

    ////////////////////////////  SLIDER  /////////////////////////////////////////////

    //Paging + Slider Function
    rotate = function () {
        setImageReelWidth();
        alert(slideTotal);
        var triggerID = $slideNumber - 1; //Get number of times to slide
        var image_reelPosition = triggerID * divWidth; //Determines the distance the image reel needs to slide
        //sets the active on the next and prev
        if ($slideNumber == 1) {
            $('#prev').attr("class", "not_active")
            $('#next').attr("class", "active")
        }
        else if ($slideNumber == slideTotal) {
            $('#next').attr("class", "not_active");
            $('#prev').attr("class", "active");
        }
        else {
            $('#prev').attr("class", "active")
            $('#next').attr("class", "active")
        };
        //Slider Animation
        $(".image_reel").animate({
            left: -image_reelPosition
        }, 500);
    };

    ////////////////////////////  SLIDER CALLS  /////////////////////////////////////////////

    //click on numbers
    $(".paging a").click(function () {
        setImageReelWidth();
        alert(slideTotal);
        setImageReelWidth();
        $active = $(this); //Activate the clicked paging
        $slideNumber = $active.attr("rel");
        rotate(); //Trigger rotation immediately
        return false; //Prevent browser jump to link anchor
    });
  • 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-29T07:20:44+00:00Added an answer on May 29, 2026 at 7:20 am

    You need to declare the variable with global scope.

    var test = 0;
    
    function func1() {
        test = 5;
    }
    
    
    function func3() {
        func1();
        alert(test);
    }
    

    Further reading on variable scope in javascript

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

Sidebar

Related Questions

This is probably a real simple question but I'm looking for the most memory
This is probably something simple but I'm scratching my head over easing with the
This is probably seriously easy to solve for most of you but I cannot
This is probably a trivial question for most but here goes... I am using
This is most likely not an easy one but here is the situation: I
I know this is most-likely a simple question but when you restore a database
This is probably quite simple but I've googled and can't find an answer. I
I'm probably missing something simple, but ListRows.Add is giving me grief. Here's the function:
The question probably sounds a little odd, but the actual task is relatively simple,
Most probably I'm missing something obvious here, but why do I need to call

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.