Agent1
New Coder
I really need urgent help in creating a permutation and combination function in my form. In this form users will input a 4 digit number (tablename___numbers) and there is a checkbox named “Box” (tablename___box) when user click on the checkbox it will count the total number of permutation and combination of the input numbers (tablename___numbers). for exmaple 0001 (3 same digit) = 4, 1100 (2 same digit = 6) and so on…
Form Id 25
I have tried a few coding but fail to get it running Please help to see where I have gone wrong. Thanks in advance.
Form Id 25
I have tried a few coding but fail to get it running Please help to see where I have gone wrong. Thanks in advance.
var tablename___box = tablename___numbers[0];
form_25.tablename___box.get(‘tablename___numbers’).getValue();
function disableBox(thisid)
{
var tablename___box = jQuery.trim($(“form_25.tablename___numbers” + thisid).val());
if(no.length != 4){
$('tablename___box ’ + thisid).attr(“disabled”, true);
$('tablename___box ’ + thisid).prop(‘checked’, false);
}
else {
var combinationCount = checkDigit(no);
$('tablename___box ’ + thisid).val(combinationCount);
$('tablename___box ’ + thisid).attr(“disabled”, false);
}
}
function checkDigit(val)
{
var b = form_25.tablename___box .get(‘tablename___numbers’).getValue();
var same = 0;
var kcount = 0;
var returnData = 1;
for(var i=0; i<4; i++){
kcount++;
for(var j=kcount; j<4; j++){
if(val.charAt(i) == val.charAt(j)){
same++;
}
}
}
if(same == 4){
returnData = 1;
}else if(same == 3){
returnData = 4;
}else if(same == 2){
returnData = 6;
}else if(same == 1){
returnData = 12;
}else{
returnData = 24;
}
return returnData;
}