Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Urgent help needed creating javascript permutation and combination function

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.
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;
}
 
user will enter any 4 digit number on the form and when he/she click on the checkbox the form will calculate the total number of permutation combination for example user enter 0001 and when they click on the checkbox the checkout will calculate the number of permutation and combination which is 4 because 3 same digit = 4 when user enetr 1234 and click the checkbox the form will respond 24
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom