Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Combine two functions

  • This topic is empty.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • #153920
    matthisco
    Participant

    Hi Folks,

    Is there a way I can combine these two functions?

    The first is to fix for the file input using railo, and the second is a post to an upload page:

      $('#fileInput').change(function () {
          $('#filenames').empty().append(_(this.files).map(function (f) {
              return $('<input type="hidden" name="filenames[]"/>').val(f.name).get(0);
          }));
      });
    
      /*jslint unparam: true */
      /*global window, $ */
      $(function () {
          'use strict';
          // Change this to the location of your server-side upload handler:
          var url = window.location.hostname === 'https://www.textsomeone.com/report_incident3/upload.cfm';
          $('#fileupload').fileupload({
              url: url,
              dataType: 'json',
              done: function (e, data) {
                  $.each(data.result.files, function (index, file) {
                      $('<p/>').text(file.name).appendTo('#files');
                  });
              },
              progressall: function (e, data) {
                  var progress = parseInt(data.loaded / data.total * 100, 10);
                  $('#progress .progress-bar').css(
                      'width',
                      progress + '%'
                  );
              }
          }).prop('disabled', !$.support.fileInput)
              .parent().addClass($.support.fileInput ? undefined : 'disabled');
      });
    
Viewing 1 post (of 1 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.