Solved

adding random number to input tag

Posted on 1998-10-21
2
159 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 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

Turn Insights into Action

Communication across every corner of your business is essential to increase the velocity of your application delivery and support pipeline. Automate, standardize, and contextualize your communication processes with xMatters.

Question has a verified solution.

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

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

717 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