Displaying Data Randomly

Kim Wong shared this problem 5 months ago
In Progress

This piece of javascript (shown below) will display six questions (in a button) in a random order. I'm wondering if this is possible in JIM


var question = new Array('', 'how long is a piece of string', 'who are you', 'where is this', 'what came first the egg or the spoon', 'question five', 'how high is this');

var numbers = new Array();

var number = 0;


do

{

var number = Math.floor(Math.random() * 6) + 1;


if (numbers.indexOf(number) == -1)

{

numbers.push(number);

document.write( '<div><input type="button" class="question" value="' + question[number] + '"></div>');

}


} while (numbers.length < 6);

Comments (3)

photo
1

Are you looking to incorporate that Javascript into Justinmind, or are you looking to create something similar to the result of the Javascript using Justinmind elements?

photo
1

Yes i want to create something similar to the result using JIM elements, however I do want to know if it's possible for javascript to change JIM wigits like buttons and text items etc

photo
1

You can incorporate Javascript into your prototype through the HTML widget. Note that the Javascript will have to relate to objects within the HTML that you define. You won't be able to use Javascript in your prototype to alter Justinmind elements.