Hello everyone,
There is a closed thread re: this (http://www.sitepoint.com/forums/showthread.php?68081-Random-Number-in-hidden-form-field) - it’s exactly what I need to do, however when I try it it’s not working for me, so I was wondering if anyone could help me revisit this topic. I need to have a confirmation number appear on a page after a user submits a form, and I need to have that same confirmation number appear in the form results without the user having to enter it, so I attempted to do this via a hidden form field.
I am able to get the confirmation number to appear on the page using the following script in the head of the document:
<script>
now = new Date();
randomNum = ‘’;
randomNum += Math.round(Math.random()*9);
randomNum += Math.round(Math.random()*9);
randomNum += now.getTime();
</script>
It’s used in conjunction with this piece of code, which does display the number on the page: Confirmation Number = <script>document.write(randomNum)</script>.
The problem is that the hidden field in the form is not displaying in the emailed form results. I’m not getting any form submission errors, and all the other fields are displaying correctly. It simply does not appear. Here is the code that I’m using for the hidden field: <input type=“hidden” name=“Confirmation:” onSubmit=“this.value=randomNum”>
If anyone could tell me what I’m missing, I’d appreciate it. This same code worked well for the person who started the previous thread, so I’m sure that I’m just missing something, but I’ve been looking at it too long now and would very much appreciate your help.
Thanks! FAFS