Jordan656
04-02-2009, 05:51 PM
hi.
I have this nifty little script I am using to generate a unique reference number for everyone that fills in my form. I have the same form in 2 locations, and it is important that I can tell (from the reference number alone) which location it came from.
I know all about sending the url etc from a form in its own hidden field, but for 100 very boring reasons I need to be able to tell from the number. I have been trying to prefix the number with letters, so from one location the number would be AAxxxxxxxx, and from the other location it would be BBxxxxxx but I have been unable to do so.
Any suggestions? Form script below (has had all irrelevant fields taken out to simplify)
<form id="formname" name="formname" method="post" action="./testcontrol.php">
<input type="text" name="orderNum" id="orderNum" />
<SCRIPT type="text/javascript">
var d = new Date();
var yr =( d.getYear() ).toString();
yr = yr.charAt(3); // final digit
var mo = ( d.getMonth() ). toString();
if ( mo.length <2 ) {mo = 0 + mo}
var hrs = ( d.getHours() ). toString();
if (hrs.length <2) {hrs = 0 + hrs}
var mns = ( d.getMinutes() ).toString();
if (mns.length <2) {mns = 0 + mns}
var secs = (d.getSeconds() ).toString();
if (secs.length <2) {secs = 0 + secs}
var oNum = yr + mo + hrs + mns + secs;
document.formname.orderNum.value = oNum;
</SCRIPT>
</form>
I have this nifty little script I am using to generate a unique reference number for everyone that fills in my form. I have the same form in 2 locations, and it is important that I can tell (from the reference number alone) which location it came from.
I know all about sending the url etc from a form in its own hidden field, but for 100 very boring reasons I need to be able to tell from the number. I have been trying to prefix the number with letters, so from one location the number would be AAxxxxxxxx, and from the other location it would be BBxxxxxx but I have been unable to do so.
Any suggestions? Form script below (has had all irrelevant fields taken out to simplify)
<form id="formname" name="formname" method="post" action="./testcontrol.php">
<input type="text" name="orderNum" id="orderNum" />
<SCRIPT type="text/javascript">
var d = new Date();
var yr =( d.getYear() ).toString();
yr = yr.charAt(3); // final digit
var mo = ( d.getMonth() ). toString();
if ( mo.length <2 ) {mo = 0 + mo}
var hrs = ( d.getHours() ). toString();
if (hrs.length <2) {hrs = 0 + hrs}
var mns = ( d.getMinutes() ).toString();
if (mns.length <2) {mns = 0 + mns}
var secs = (d.getSeconds() ).toString();
if (secs.length <2) {secs = 0 + secs}
var oNum = yr + mo + hrs + mns + secs;
document.formname.orderNum.value = oNum;
</SCRIPT>
</form>