Click here to Skip to main content
15,499,430 members
Home / Discussions / JavaScript
   

JavaScript

 
Generalhow can we set random image in my asp website? Pin
GDdixit31-Dec-12 6:43
MemberGDdixit31-Dec-12 6:43 
AnswerRe: how can we set random image in my asp website? Pin
Sandeep Mewara4-Jan-13 3:59
mveSandeep Mewara4-Jan-13 3:59 
GeneralRe: how can we set random image in my asp website? Pin
GDdixit22-Jan-13 1:52
MemberGDdixit22-Jan-13 1:52 
GeneralRe: how can we set random image in my asp website? Pin
Sandeep Mewara22-Jan-13 3:34
mveSandeep Mewara22-Jan-13 3:34 
Questiongenerate random numbers from specific array Pin
aeman29-Dec-12 23:16
Memberaeman29-Dec-12 23:16 
AnswerRe: generate random numbers from specific array Pin
Sandeep Mewara4-Jan-13 4:06
mveSandeep Mewara4-Jan-13 4:06 
AnswerRe: generate random numbers from specific array Pin
Joe DiNatale4-Jan-13 10:28
MemberJoe DiNatale4-Jan-13 10:28 
AnswerRe: generate random numbers from specific array Pin
John Y.19-Feb-13 6:47
MemberJohn Y.19-Feb-13 6:47 
If you need to use this often for arrays, I would add a function to the array prototype:
JavaScript
Array.prototype.randomPick = function(){
	var M = this.length-1;
	var N = 0;
	var randomIndex = Math.floor(Math.random()*(1+M-N))+N;
	return this[randomIndex];
};

Then you can call it:
JavaScript
var arr = [2,3,4,5,4,6,8,9,7];
alert(arr.randomPick());

________
John Y.
Developer

Questionaccess info popup page Pin
apadana_198928-Dec-12 7:58
Memberapadana_198928-Dec-12 7:58 
AnswerRe: access info popup page Pin
Sandeep Mewara4-Jan-13 4:13
mveSandeep Mewara4-Jan-13 4:13 
AnswerRe: access info popup page Pin
vinodkumarnie18-Jan-13 23:56
Membervinodkumarnie18-Jan-13 23:56 
Questioncontrol other page Pin
apadana_198928-Dec-12 7:50
Memberapadana_198928-Dec-12 7:50 
AnswerRe: control other page Pin
aeman29-Dec-12 23:34
Memberaeman29-Dec-12 23:34 
AnswerRe: control other page Pin
jkirkerx31-Dec-12 11:34
professionaljkirkerx31-Dec-12 11:34 
QuestionProblem With jQuery AppendTo and Data Attributes Pin
AnalogNerd28-Dec-12 4:41
MemberAnalogNerd28-Dec-12 4:41 
Questioncss Pin
SINNAM28-Dec-12 2:32
MemberSINNAM28-Dec-12 2:32 
AnswerRe: css Pin
Keith Barrow28-Dec-12 3:33
professionalKeith Barrow28-Dec-12 3:33 
Questioncss Pin
SINNAM28-Dec-12 2:29
MemberSINNAM28-Dec-12 2:29 
AnswerRe: css Pin
Sandeep Mewara4-Jan-13 4:14
mveSandeep Mewara4-Jan-13 4:14 
AnswerFB Connect Javascript Pin
sasikumar.prs27-Dec-12 0:29
Membersasikumar.prs27-Dec-12 0:29 
GeneralRe: FB Connect Javascript Pin
GDdixit31-Dec-12 6:40
MemberGDdixit31-Dec-12 6:40 
GeneralRe: FB Connect Javascript Pin
jkirkerx31-Dec-12 11:36
professionaljkirkerx31-Dec-12 11:36 
AnswerRe: FB Connect Javascript Pin
Sandeep Mewara4-Jan-13 4:17
mveSandeep Mewara4-Jan-13 4:17 
QuestionGridview Problem Pin
jojoba201122-Dec-12 6:05
Memberjojoba201122-Dec-12 6:05 
AnswerRe: Gridview Problem Pin
Sandeep Mewara4-Jan-13 4:25
mveSandeep Mewara4-Jan-13 4:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.