Skip to content

Instantly share code, notes, and snippets.

@cortezcristian
Created June 6, 2014 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cortezcristian/57a1d1d2ac9635bf70c0 to your computer and use it in GitHub Desktop.
Save cortezcristian/57a1d1d2ac9635bf70c0 to your computer and use it in GitHub Desktop.
Auto Complete VPcup
function getGoals() {
var p = parseInt((Math.random()*100),10),
r = 0,
g = parseInt((Math.random()*10),10);
if(p<=25) {
r = 0;
} else if(p<=40) {
r = 1;
} else if(p<=50) {
r = 2;
} else {
if(g>5){
r = g-5;
} else {
r = g;
}
}
return r;
}
var i = parseInt($("input[name*='partido']").eq(0).attr('name').replace(/partido\[/,'').replace(/\].*/,""),10),
l = 5, f = i+l;
for(var j=i;j<=f;j++) {
console.log("partido["+j+"]");
for(var z=1;z<=2;z++) {
console.log("partido["+j+"]["+z+"]", $("input[name='partido["+j+"]["+z+"]']").val());
$("input[name='partido["+j+"]["+z+"]']").val(getGoals())
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment