I'm trying to generate a random number in a Perl script (confirmation #), and I would like to populate the field of a generated form with the random number. I'm using a random # generating Javascript as follows in the printed HTML in my Perl statement:
print "Content-type: text/html\n\n" unless
$content_type_printed++;
print qq!
<html><head><title>Coupons</title></head> <form method="POST" action=" <input type="hidden" name="confirmnumber" value="<SCRIPT language="JavaScript"><!--
var maxNumber = 1000;
var randomNumber = Math.round(maxNumber * Math.random());
//--></SCRIPT>
<SCRIPT language="JavaScript"><!--
document.write(randomNumber);
//--></SCRIPT>
</td></tr>
Now I know that a form can't take a Javascript as a "value" - however, I'm at a loss for how to get the random number in there (I need to do it at this step, so that both people I've got receiving email verfication get the same number) - thanks for any suggestions.
Ethan Altaratz
print "Content-type: text/html\n\n" unless
$content_type_printed++;
print qq!
<html><head><title>Coupons</title></head> <form method="POST" action=" <input type="hidden" name="confirmnumber" value="<SCRIPT language="JavaScript"><!--
var maxNumber = 1000;
var randomNumber = Math.round(maxNumber * Math.random());
//--></SCRIPT>
<SCRIPT language="JavaScript"><!--
document.write(randomNumber);
//--></SCRIPT>
</td></tr>
Now I know that a form can't take a Javascript as a "value" - however, I'm at a loss for how to get the random number in there (I need to do it at this step, so that both people I've got receiving email verfication get the same number) - thanks for any suggestions.
Ethan Altaratz