PDA

View Full Version : please find errors if any make them correct



thimmappa449
10-06-2010, 11:11 AM
please find if any errors are there ,and here the monthNames dayNames yearNames are declared in another file,and the results obtained after shuffle they are diplayed in the table along column wise as shown the figure found in url http://www.urbanspoon.com/spin-widget .
if you find any mistakes in this please make them correct
i dont know exactly whether im correct or not
function shuffle()
{



var randomNumber;

var len=this.length-1;

randomNumber = Math.floor(Math.random()*len);
// document.write(randomNumber);


if(randomNumber > len)
{
randomNumber =len;
}


for(var i =0; i <= randomNumber; i++)
{



if(i !=len)
{
this[i] = this[i+1];
}
else
{
temp =this[i];

this[i]=this[0];

this[0]=temp ;
}



}

}

function autoSpin(
{

//var monthNames = new Array('Active','Passive','Bargain','Vegas','Value');

monthNames.shuffle();

var shuffleresults= monthNames.join("<br>");
var len = shuffleresults.rows.length, i;
if(results.rows.length > 0) {


monthNames[0] = shuffleresults.rows.item(0).monthNames[0];
monthNames[1] = shuffleresults.rows.item(1).monthNames[1];
monthNames[2] = shuffleresults.rows.item(2).monthNames[2];
monthNames[3] = shuffleresults.rows.item(3).monthNames[3];
monthNames[4] = shuffleresults.rows.item(4).monthNames[4];

//spinnerId = shuffleresults.rows.item(0).spinnerId;



document.getElementById('monthNames[0]').innerHTML = monthNames[0];
document.getElementById('monthNames[1]').innerHTML = monthNames[1];
document.getElementById('monthNames[2]').innerHTML = monthNames[2];
document.getElementById('monthNames[3]').innerHTML = monthNames[3];
document.getElementById('monthNames[4]').innerHTML = monthNames[4];

}
dayNames.shuffle();

var shuffleresults1= dayNames.join("<br>");
var len = shuffleresults1.rows.length, i;
if(results.rows.length > 0) {


dayNames[0] = shuffleresults1.rows.item(0).dayNames[0];
dayNames[1] = shuffleresults1.rows.item(1).dayNames[1];
dayNames[2] = shuffleresults1.rows.item(2).dayNames[2];
dayNames[3] = shuffleresults1.rows.item(3).dayNames[3];
dayNames[4] = shuffleresults1.rows.item(4).dayNames[4];

//spinnerId = shuffleresults1.rows.item(0).spinnerId;



document.getElementById('dayNames[0]').innerHTML = dayNames[0];
document.getElementById('dayNames[1]').innerHTML = dayNames[1];
document.getElementById('dayNames[2]').innerHTML = dayNames[2];
document.getElementById('dayNames[3]').innerHTML = dayNames[3];
document.getElementById('dayNames[4]').innerHTML = dayNames[4];

}


yearNames.shuffle();

var shuffleresults2= yearNames.join("<br>");
var len = shuffleresults2.rows.length, i;
if(results.rows.length > 0) {


yearNames[0] = shuffleresults2.rows.item(0).yearNames[0];
yearNames[1] = shuffleresults2.rows.item(1).yearNames[1];
yearNames[2] = shuffleresults2.rows.item(2).yearNames[2];
yearNames[3] = shuffleresults2.rows.item(3).yearNames[3];
yearNames[4] = shuffleresults2.rows.item(4).yearNames[4];

//spinnerId = shuffleresults2.rows.item(0).spinnerId;



document.getElementById('yearNames[0]').innerHTML = yearNames[0];
document.getElementById('yearNames[1]').innerHTML = yearNames[1];
document.getElementById('yearNames[2]').innerHTML = yearNames[2];
document.getElementById('yearNames[3]').innerHTML = yearNames[3];
document.getElementById('yearNames[4]').innerHTML = yearNames[4];

}




}
Thanks in advance