D
D
del9937882015-10-06 03:09:48
JavaScript
del993788, 2015-10-06 03:09:48

How to decline number of upload.files.length?

Hello. Please look at the code.

function declOfNum(number, titles) 
{ 
    cases = [2, 0, 1, 1, 1, 2]; 
    return titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; 
}
function get_files() {
    var upload = document.getElementById('fileFF');
    var resultat = declOfNum(upload.files.length,['файл','файла','файлов']);
    $('#pupl').text('Вы выбрали' + resultat);
}

It doesn't output upload.files.length. The output is: "You have selected a file" .upload.files.length is the number of selected files in the input file multiple.
Despite the fact that everything works in this code, though there is no declension there ...
function get_files() {
    var upload = document.getElementById('fileFF');
    $('#pupl').text('Вы выбрали' + upload.files.length + ' файл');
}

Can you please tell me how to decline upload.files.length?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2015-10-06
@del993788

function get_files() {
    var upload = document.getElementById('fileFF');
    var resultat = declOfNum(upload.files.length,['файл','файла','файлов']);
    $('#pupl').text('Вы выбрали '  + upload.files.length + resultat);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question