javascript - Krajee Bootstrap file input dynamic maxFilecount -


i want set maxfilecount dynamic nums if input field changed.

my code:

<input value="" name="check_nums" class="check_nums"> 

krajee fileinput:

$(document).on('ready', function() {     $('#file-th').fileinput({          var check_nums = $(".check_nums").val();          showuploadedthumbs: false,         language: 'th',         uploadasync: false,         maxfilecount: [check_nums],         resizepreference: 'height',         resizeimage: true,         overwriteinitial: false,         validateinitialcount: true,         showupload: false,          allowedfileextensions: ['jpg', 'png', 'jpeg'],         previewsettings: {             image: {width: "auto", height: "100px"},             object: {width: "213px", height: "160px"},         },         layouttemplates: {             actions: '<div class="file-actions">\n' +                 '    <div class="file-footer-buttons">\n' +                 '        {delete}' +                 '    </div>\n' +                 '</div>',         }     }).on("filebatchselected", function(event, files) {      }); }); 

hope help:

first change variable declaration position correct way declare initial stage.

$(document).on('ready', function() {     var check_nums = $(".check_nums").val();     $('#file-th').fileinput({         showuploadedthumbs: false,         language: 'th',         uploadasync: false,         maxfilecount: check_nums,          resizepreference: 'height',         resizeimage: true,         overwriteinitial: false,         validateinitialcount: true,         showupload: false,             allowedfileextensions: ['jpg', 'png', 'jpeg'],         previewsettings: {             image: {width: "auto", height: "100px"},             object: {width: "213px", height: "160px"},         },         layouttemplates: {             actions: '<div class="file-actions">\n' +                 '    <div class="file-footer-buttons">\n' +                 '        {delete}' +                 '    </div>\n' +                 '</div>',         }     }).on("filebatchselected", function(event, files) {      }); }); 

then bind change event input box , assign input value max limit file input.

$(".check_nums").change(function(){     $("#file-th").fileinput('maxfilecount',$(this).val()); }); 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -