?
Solved

adding random number to input tag

Posted on 1998-10-21
2
Medium Priority
?
162 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

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

Accepted Solution

by:
b2pi earned 400 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

Docker-Compose to Simplify Multi-Container Builds

Our veteran DevOps Author takes you through how to build a multi-container environment, managed with a single utility in order to simplify your deployments.

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Suggested Courses

762 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