Skip to content

Instantly share code, notes, and snippets.

@scragg0x
Last active December 19, 2015 01:49
Show Gist options
  • Save scragg0x/5878486 to your computer and use it in GitHub Desktop.
Save scragg0x/5878486 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>CSV Maker</title>
<script>
function get(id){
return document.getElementById(id);
}
function rand(min, max){
min = parseInt(min);
max = parseInt(max);
return Math.floor((Math.random()*(max-min))+min);
}
function go(){
var i, j;
var str = '';
for(i=0;i<get('rows').value;i++){
for(j=0;j<get('cols').value;j++){
str += rand(get('min').value, get('max').value) + ",";
}
str = str.replace(/,+$/, '');
str += "\n";
}
get('data').value = str;
}
</script>
</head>
<body>
<div>
Cols <input type=text id=cols size=3 value=2 />
Rows <input type=text id=rows size=3 value=5 />
Integer Range Min: <input type=text id=min size=5 value=1000 /> Max: <input type=text id=max size=5 value=9999 />
<input onclick='go()' type='button' value='Go!' />
</div>
<br /><br />
<div><textarea onclick='this.select()' id=data style='width:500px;height:500px;'></textarea></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment