Skip to content

Instantly share code, notes, and snippets.

@mixdev
Created September 8, 2013 19:26
Show Gist options
  • Save mixdev/6487670 to your computer and use it in GitHub Desktop.
Save mixdev/6487670 to your computer and use it in GitHub Desktop.
Creates alpha numeric coupon codes with specified chars length. Not duplicates checks.
<html>
<head>
<title>Coupon generator</title>
</head>
<body bgcolor="white" text="black">
<script>
//var txt = 'aabcdefghijklmnopqrstuvwxyz0123456789';
var txt = 'aabcdefghjkmnpqrstuvwxyz23456789';//Remove indistinguishable chars like o,0,i,l,1
var ln=txt.length;
var codelen = 5;
var howmanycodes = 100;
var code='';
for(j=0;j<howmanycodes;j++){
for(i=0;i<codelen;i++) code += txt.charAt(Math.floor(Math.random() * ln) );
code +="<br>";
}
document.write(code.toUpperCase());
</script></body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment