Solved

adding random number to input tag

Posted on 1998-10-21
2
147 Views
Last Modified: 2013-12-25
I'm using a perl cgi script which generates input tags for a form.  I'd like the value for one of the input tags to be randomly generated.
ie.

print "<TD><INPUT NAME=\"Filename\" TYPE=\"text\" SIZE=\"25\" MAXLENGTH=\"25\" value=\"I'd like a random number here\"></TD></TR>\n";

In the above Input tag, I'd like the "value" portion to be a random number of at least 8 digits.  Can someone help me? :)
0
Comment
Question by:kenneth022597
2 Comments
 

Author Comment

by:kenneth022597
ID: 1829239
Edited text of question
0
 
LVL 5

Accepted Solution

by:
b2pi earned 100 total points
ID: 1829240
Make sure you're using perl5.004 or later. Assuming that you want an integer:

print substr(sprintf("%.8f",rand(1.0)),2)

If you're using a perl before 5.004, add a call at the top of your program (call it only once)

srand($$ + time);


0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now