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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:19:21+00:00 2026-05-27T00:19:21+00:00

var Rand1 = Math.floor(Math.random()*3); var Rand2 = Rand1; while ( Rand2 == Rand1 ){

  • 0
var Rand1 = Math.floor(Math.random()*3);
var Rand2 = Rand1;

while ( Rand2 == Rand1 ){
    var Rand2 = Math.floor(Math.random()*3);
}
var step1 = Rand1;
var step2 = Rand2;

function moveto(step1, step2) {
    var w = $(document).width();
    $('#full').animate({
        left: -(step1*w)
    },  {
    duration: 3000,
    });
}

//what element is this supposed to be?
class="img bg-img1" OnClick="moveto('1');">

My problem is: I need to assign the random number given by Rand1 into the OnClick=”moveto(‘Rand1’); how do i do that ?

  • 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-27T00:19:22+00:00Added an answer on May 27, 2026 at 12:19 am

    Try this and remove the onclick from your inline button/element: http://jsfiddle.net/GApnw/

    function randomNumbers() {
        var Rand1 = Math.floor(Math.random() * 3);
        var Rand2 = Rand1;
        while (Rand2 == Rand1) {
            var Rand2 = Math.floor(Math.random() * 3);
        }
        return [Rand1, Rand2];
    }
    
    function moveto(step1, step2) {
        var w = $(document).width();
        $('#full').animate({
            left: -(step1 * w)
        }, {
            duration: 3000,
        });
        alert(step1 + " " + step2);
    }
    
    $(function(){
        $(".img").click(function(){
            var randomNum = randomNumbers();
            moveto(randomNum[0], randomNum[1]);
        });
    });
    

    Or do the call to get the RandomNumbers within your moveto, if you don’t give numbers elsewhere.

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

Sidebar

Related Questions

var thumbs = document.getElementsByTagName(img); for (var i=0; i<thumbs.length; i++) { Core.addEventListener(thumbs[i], click, function() {alert(i);});
I'm looking for a way to influence Math.random(). I have this function to generate
I have two functions function ShowCrossWord(var randN) { randomnumber = randN; $(document).ready(function() { $.get(crosswords.xml,{},function(xml){
var y = new w(); var x = y.z; y.z= function() { doOneThing(); x();
I am trying to animate random properties on the x and y's //generates a
Let us say I have the following: var foo = (function(){ var bar =
I have a question regarding javascript Math.random() : I have (for a game I'm
I have a JavaScript function as follows: function popup(username) { var req = createAjaxObject();
Javascript's MATH object has a random method that returns from the set [0,1) 0
Hy guiz. Ok Rand1 displays 0 1 and 2 and i need Rand2 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.