thimmappa494
19 Oct 2010, 11:48 PM
HI all
I am new to this type of applications and forum too .i am developing an application in java-script and you can see that type of application in the URL http://www.urbanspoon.com/spin-widget.Fo that application i have done all the coding but i struck ed while doing for the spin button in that application.kindly help me in that aspect.
at my level best i have done the following but it is not getting executed.here is the code
Array.prototype.shuffle = shuffle;
function shuffle()
{
var tempSlot;
var randomNumber;
for(var i =0; i != this.length; i++)
{
randomNumber = Math.floor(Math.random() * this.length);
tempSlot = this[i];
this[i] = this[randomNumber];
this[randomNumber] = tempSlot;
}
}
i have written the shuffle function and i used that function in the index file as shown below
function autoSpin()
{
myArray.shuffle();
var shuffleresults= myArray.join("br<>");
document.getElementById("shake").innerHTML = shuffleresults;
//var Date.monthNames = new Array('Active','Passive','Bargain','Vegas','Value');
Date.monthNames.shuffle();
var shuffleresults= Date.monthNames.join("br<>");
var len = shuffleresults.rows.length, i;
if(shuffleresults.rows.length > 0) {
alert("hi");
Date.monthNames[0] = shuffleresults.rows.item[0].Date.monthNames[0];
Date.monthNames[1] = shuffleresults.rows.item[1].Date.monthNames[1];
Date.monthNames[2] = shuffleresults.rows.item[2].Date.monthNames[2];
Date.monthNames[3] = shuffleresults.rows.item[3].Date.monthNames[3];
Date.monthNames[4] = shuffleresults.rows.item[4].Date.monthNames[4];
//spinnerId = shuffleresults.rows.item[0].spinnerId;
}
document.getElementById('Date.monthNames[0]').innerHTML = Date.monthNames[0];
document.getElementById('Date.monthNames[1]').innerHTML = Date.monthNames[1];
document.getElementById('Date.monthNames[2]').innerHTML = Date.monthNames[2];
document.getElementById('Date.monthNames[3]').innerHTML = Date.monthNames[3];
document.getElementById('Date.monthNames[4]').innerHTML = Date.monthNames[4];
Date.dayNames.shuffle();
//var Date.dayNames=new Array('LEAPS','Earnings','Economic','Weekly','Daily');
var shuffleresults1= Date.dayNames.join("<br>");
var len = shuffleresults1.columns.length, i;
if(shuffleresults1.columns.length > 0) {
Date.dayNames[0] = shuffleresults1.columns.item[0].Date.dayNames[0];
Date.dayNames[1] = shuffleresults1.columns.item[1].Date.dayNames[1];
Date.dayNames[2] = shuffleresults1.columns.item[2].Date.dayNames[2];
Date.dayNames[3] = shuffleresults1.columns.item[3].Date.dayNames[3];
Date.dayNames[4] = shuffleresults1.columns.item[4].Date.dayNames[4];
}
//spinnerId = shuffleresults1.columns.item[0].spinnerId;
document.getElementById('Date.dayNames[0]').innerHTML = Date.dayNames[0];
document.getElementById('Date.dayNames[1]').innerHTML = Date.dayNames[1];
document.getElementById('Date.dayNames[2]').innerHTML = Date.dayNames[2];
document.getElementById('Date.dayNames[3]').innerHTML = Date.dayNames[3];
document.getElementById('Date.dayNames[4]').innerHTML = Date.dayNames[4];
//var Date.yearNames=new Array('2$','1$','50 cents','25 cents','5 cents');
Date.yearNames.shuffle();
var shuffleresults2= Date.yearNames.join("<br>");
var len = shuffleresults2.columns.length, i;
if(shuffleresults2.columns.length > 0) {
Date.yearNames[0] = shuffleresults2.columns.item[0].Date.yearNames[0];
Date.yearNames[1] = shuffleresults2.columns.item[1].Date.yearNames[1];
Date.yearNames[2] = shuffleresults2.columns.item[2].Date.yearNames[2];
Date.yearNames[3] = shuffleresults2.columns.item[3].Date.yearNames[3];
Date.yearNames[4] = shuffleresults2.columns.item[4].Date.yearNames[4];
//spinnerId = shuffleresults2.rows.item[0].spinnerId;
}
document.getElementById('Date.yearNames[0]').innerHTML = Date.yearNames[0];
document.getElementById('Date.yearNames[1]').innerHTML = Date.yearNames[1];
document.getElementById('Date.yearNames[2]').innerHTML = Date.yearNames[2];
document.getElementById('Date.yearNames[3]').innerHTML = Date.yearNames[3];
document.getElementById('Date.yearNames[4]').innerHTML = Date.yearNames[4];
}
here the function autoSpin is given as on-click event for the spin button in the application and the arrays are Date.monthNames, Date.dayNames, Date.yearNames.
please find errors if any and correct them
Thanks in advance....
I am new to this type of applications and forum too .i am developing an application in java-script and you can see that type of application in the URL http://www.urbanspoon.com/spin-widget.Fo that application i have done all the coding but i struck ed while doing for the spin button in that application.kindly help me in that aspect.
at my level best i have done the following but it is not getting executed.here is the code
Array.prototype.shuffle = shuffle;
function shuffle()
{
var tempSlot;
var randomNumber;
for(var i =0; i != this.length; i++)
{
randomNumber = Math.floor(Math.random() * this.length);
tempSlot = this[i];
this[i] = this[randomNumber];
this[randomNumber] = tempSlot;
}
}
i have written the shuffle function and i used that function in the index file as shown below
function autoSpin()
{
myArray.shuffle();
var shuffleresults= myArray.join("br<>");
document.getElementById("shake").innerHTML = shuffleresults;
//var Date.monthNames = new Array('Active','Passive','Bargain','Vegas','Value');
Date.monthNames.shuffle();
var shuffleresults= Date.monthNames.join("br<>");
var len = shuffleresults.rows.length, i;
if(shuffleresults.rows.length > 0) {
alert("hi");
Date.monthNames[0] = shuffleresults.rows.item[0].Date.monthNames[0];
Date.monthNames[1] = shuffleresults.rows.item[1].Date.monthNames[1];
Date.monthNames[2] = shuffleresults.rows.item[2].Date.monthNames[2];
Date.monthNames[3] = shuffleresults.rows.item[3].Date.monthNames[3];
Date.monthNames[4] = shuffleresults.rows.item[4].Date.monthNames[4];
//spinnerId = shuffleresults.rows.item[0].spinnerId;
}
document.getElementById('Date.monthNames[0]').innerHTML = Date.monthNames[0];
document.getElementById('Date.monthNames[1]').innerHTML = Date.monthNames[1];
document.getElementById('Date.monthNames[2]').innerHTML = Date.monthNames[2];
document.getElementById('Date.monthNames[3]').innerHTML = Date.monthNames[3];
document.getElementById('Date.monthNames[4]').innerHTML = Date.monthNames[4];
Date.dayNames.shuffle();
//var Date.dayNames=new Array('LEAPS','Earnings','Economic','Weekly','Daily');
var shuffleresults1= Date.dayNames.join("<br>");
var len = shuffleresults1.columns.length, i;
if(shuffleresults1.columns.length > 0) {
Date.dayNames[0] = shuffleresults1.columns.item[0].Date.dayNames[0];
Date.dayNames[1] = shuffleresults1.columns.item[1].Date.dayNames[1];
Date.dayNames[2] = shuffleresults1.columns.item[2].Date.dayNames[2];
Date.dayNames[3] = shuffleresults1.columns.item[3].Date.dayNames[3];
Date.dayNames[4] = shuffleresults1.columns.item[4].Date.dayNames[4];
}
//spinnerId = shuffleresults1.columns.item[0].spinnerId;
document.getElementById('Date.dayNames[0]').innerHTML = Date.dayNames[0];
document.getElementById('Date.dayNames[1]').innerHTML = Date.dayNames[1];
document.getElementById('Date.dayNames[2]').innerHTML = Date.dayNames[2];
document.getElementById('Date.dayNames[3]').innerHTML = Date.dayNames[3];
document.getElementById('Date.dayNames[4]').innerHTML = Date.dayNames[4];
//var Date.yearNames=new Array('2$','1$','50 cents','25 cents','5 cents');
Date.yearNames.shuffle();
var shuffleresults2= Date.yearNames.join("<br>");
var len = shuffleresults2.columns.length, i;
if(shuffleresults2.columns.length > 0) {
Date.yearNames[0] = shuffleresults2.columns.item[0].Date.yearNames[0];
Date.yearNames[1] = shuffleresults2.columns.item[1].Date.yearNames[1];
Date.yearNames[2] = shuffleresults2.columns.item[2].Date.yearNames[2];
Date.yearNames[3] = shuffleresults2.columns.item[3].Date.yearNames[3];
Date.yearNames[4] = shuffleresults2.columns.item[4].Date.yearNames[4];
//spinnerId = shuffleresults2.rows.item[0].spinnerId;
}
document.getElementById('Date.yearNames[0]').innerHTML = Date.yearNames[0];
document.getElementById('Date.yearNames[1]').innerHTML = Date.yearNames[1];
document.getElementById('Date.yearNames[2]').innerHTML = Date.yearNames[2];
document.getElementById('Date.yearNames[3]').innerHTML = Date.yearNames[3];
document.getElementById('Date.yearNames[4]').innerHTML = Date.yearNames[4];
}
here the function autoSpin is given as on-click event for the spin button in the application and the arrays are Date.monthNames, Date.dayNames, Date.yearNames.
please find errors if any and correct them
Thanks in advance....