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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:24:47+00:00 2026-06-04T08:24:47+00:00

I want to make a button to start the onclick to make the random

  • 0

I want to make a button to start the onclick to make the random numbers keep running,(use

  1. or 2. to call) but if I press it , the error message shows that “Uncaught

ReferenceError: spanArray is not defined” but above the number is still running, I cannot

understand where is the wrong place.

PS But if I use 3 it work normally.

Thx!

thx complete code I try by 3 is http://jsfiddle.net/eVyjC/

function computeRandom(){
// skip code: have used loop to create six spans already
var spanArray = document.getElementsByTagName("span");
//1.document.write("<input type =  button  value = 'start' onclick = \"passKeepMove(value,spanArray) \"  name = button1>");
//2.document.write("<input type =  button  value = 'start' onclick =  \"setInterval(function(){keepMove(value,spanArray);}, 10) \"  name = button1>");
//3.setInterval(function(){keepMove(value,spanArray);}, 10) ;
   }


function keepMove(val,sp){//call by pointer 

    var index = parseInt(Math.random()*43);//set a increment to avoid repeatition

    for( i = 0; i < sp.length; i++){
    sp[i].innerHTML = val[i+index];
    }
}


function passKeepMove(v,s){
    setInterval(function(){keepMove(v, s);}, 10);
}
  • 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-04T08:24:49+00:00Added an answer on June 4, 2026 at 8:24 am

    The var in front of var spanArray is making spanArray a local variable. So you can not access it outside of computeRandom‘s function scope.

    You need to make it global or come up with a better design so you do not need global variables.

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

Sidebar

Related Questions

I want to make a C++ button on Start>Run i.e but when I do
i want simply make this code i have one button but when i click
I want to make a button that starts my php script after I click
I want to make preview button as usual form button next to submit button(as
I am writing an iPhone programer, and I want to make a button with
I want to make a Follow a button like Twitter Follow in JQuery, Json
i want to make a dynamic list with buttons on it. My button in
My goal here is to make a button. I want the text to sit
I want to, when the user clicks a button on my website, to make
I've got some Buttons that I want to make un-clickable (but still appear on

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.