generate a unique invoice number -...

User 2611054 Photo


Registered User
35 posts

Can anyone please show me how to generate a unique invoice number in a confirmation page on my form that payment is invoice ? When the user clicks on the submit button it will take them to a confirmation page where the automatically generated Invoice Number will display.
Thanks
User 128685 Photo


Ambassador
12 posts

add a hidden field in yourform.fb by Form options e.g.name="refnumber"
then
add javascript function in yourform.html
<head>
....
<script type="text/javascript" language="javascript">
function refno() /*e.g. generate random number , you can rewrite for your own*/
{
document.getElementById('ref').value = Math.floor((Math.random()*1000000000)+1);
}
</script>
</head>
and your hidden field is locate at bottom of yourform.html
<input type="hidden" id="ref" name="refnumber" value="" />
</form>
User 2611054 Photo


Registered User
35 posts

first thank you for help
1- I add a hidden field its name is "refnumber" and the value is ''value''
2-after that i made " HTML Element " on my form and paste this cod on it
<head>
....
<script type="text/javascript" language ="javascript">
function refno() /*invoice number*/
{
document.getElementById('ref').value = Math.floor((Math.random()*1000000000)+1);
}
</script>
</head>
after that
3- I add another "HTML element" on my form and paste this cod
<input type="hidden" id="ref" name="refnumber" value="" />
</form>

coz I'm not good in english language
I tread to understand the steps you wrote but it is not work... when i use the way i wrote .
I know I have wrong cuz i don't understand
so can you please write again the way of make the Auto number in confirm pag .
thank you
User 187934 Photo


Senior Advisor
20,190 posts

Add this script to a HTML element.
<script src="common/libs_js/jquery-1.4.4.min.js"></script> <script type="text/javascript">$(document).ready(function(){
var number = 1 + Math.floor(Math.random() * 999999999);
//$("#item1").hide();
$("input[name='myfieldname']").val(number);

});</script>

Adjust the item1 to the number element on your form that you want the random number to show in.
Remove the // from //$("#item1").hide(); if you don't want it to be see by the user.
Adjust the 999999999 to the max value set for your input or less.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 128685 Photo


Ambassador
12 posts

Step 1- add a hidden field its name is "refnumber" and the value is ''value''
Step 2-after that made " HTML Element " on my form and paste this cod on it
<head>
....
<script type="text/javascript" language ="javascript">
function refno() /*invoice number*/
{
document.getElementById('ref').value = Math.floor((Math.random()*1000000000)+1);
}
</script>
</head>
Step 3 - change <body> to <body onload="refno()">
after that
Step 4 - change <input type="hidden" name="refnumber" value="Value" />
to <input type="hidden" id="ref" name="refnumber" value=""/>
</form>
User 2611054 Photo


Registered User
35 posts

its work thank you a lot :)
I have another Q
Is there a possibility that this auto numbers are repeated ?
I mean
can I make this ''auto number'' as ''Primary key'' om mysql table ?
thank you
User 2796854 Photo


Registered User
44 posts

old post :) but need help with the same question:

Eric, I followed the steps you entered (at least I think I did) and after the form i submitted the results does not show the ref number.
Here what I did:

1. add an html element to my form

2. pasted: <script src="common/libs_js/jquery-1.4.4.min.js"></script> <script type="text/javascript">$(document).ready(function(){
var number = 1 + Math.floor(Math.random() * 999999999);
//$("#item1").hide();
$("input[name='myfieldname']").val(number);

});</script>

3. added a text field element to my form and named it myfieldname

4. exported the project

5. submitted the form - results had all the resulted associated with [_form_results_]


Any thoughts?
User 187934 Photo


Senior Advisor
20,190 posts

Tim, can you share a link to your form?
Also try it this way.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
var jQ = $.noConflict(true);
jQ(document).ready(function(){
var number = 1 + Math.floor(Math.random() * 999999999);
//jQ("#item1").hide();
jQ("input[name='myfieldname']").val(number);

});</script>
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 2796854 Photo


Registered User
44 posts

It WORKED !!!!


:) Thanks Eric.
User 187934 Photo


Senior Advisor
20,190 posts

Cool. :cool:
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.