.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Easy Web
Imran Ghani

Home >> Forum >> JavaScript/VBScript >> Post New QuestionBookmark and Share Subscribe to Forum

give me a program of random no. generatio... and whats the problem in below code.?

Posted By: jay     Posted Date: March 12, 2010    Points:2   Category :JavaScript/VBScript
give me a program of random no. generatio... and whats the problem in below code in javascript?
<html>

<head>

<script type="text/javascript">


function randm()
{

alert("HI");


var a = new Array();
var b = new Array();


b[0]="one";
b[1]="two";
b[2]="three";
b[3]="four";
b[4]="five";
b[5]="six";

var i;
var j;
var f;


for(i=0;i<=5;i++)
{

var r=math.random();


r*=10;

b[i]=ParseInt(r);

for(j=0;j<=(i-1);j++)
{

if(b[j]==b[i])

i--

}




}

for(f=0;f<=5;f++)

document.write("random no. is "+a[b[f]]+"<br>");

}


</script>

</head>

<body onload="randm()">

</body>

</html>

Responses
Author: jay             
Posted Date: March 12, 2010     Points: 5   



Author: jay             
Posted Date: March 12, 2010     Points: 5   



Author: Naresh             
Posted Date: March 17, 2010     Points: 5   

hi,

This is the code Random Number Generation,


public string ticketno()
{
StringBuilder builder = new StringBuilder("IBM-000");
builder.Append(randomno(1, 99999));
return builder.ToString();
}
private int randomno(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}

this.TextBox1.Text = ticketno();


The OutpUt will be,


TextBox =IBM-00045556


Thanks,
malathy.v

Thanks
Naresh
Author: susant             
Posted Date: March 20, 2010     Points: 5   

hi just try this this will give random number + text


string str = Guid.NewGuid().ToString();
string ID = str.Substring(0, 5).ToString();
TextBox1.Text=ID.ToString();



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend