13

i am using a jquery plugin and my code look somthing like this.

<script type="text/javascript">
$(document).ready(function() {
    $('#fileUpload').uploadify({ 
      'uploader': 'img/uploadify.swf',
      'script': 'uploadify.php',
      'folder': 'upload',
      'auto' : 'true',
      'cancelImg': 'img/cancel.png',
      'fileDesc': 'jpg/jpeg',
      'displayData': 'percentage',
      'fileExt': "*.jpg;*.jpeg",
      'sizeLimit' : '8388608',
      'fileDataName' : 'file',
      onComplete: function(event, queueID, fileObj, reposnse, data) 
      {
     $('#filesUploaded').append('<a href='+fileObj.filePath+'>'+fileObj.name+'</a><br>');
     $("#firstUpload").remove();

        }
      }); }); 

$(document).ready(function() {
    $('#fileUpload2').uploadify({ 
      'uploader': 'img/uploadify.swf',
      'script': 'uploadify.php',
      'folder': 'upload',
      'auto' : 'true',
      'cancelImg': 'img/cancel.png',
      'fileDesc': 'jpg/jpeg',
      'displayData': 'percentage',
      'fileExt': "*.jpg;*.jpeg",
      'sizeLimit' : '8388608',
      'fileDataName' : 'file',
      onComplete: function(event, queueID, fileObj, reposnse, data) 
      {
     $('#filesUploaded').append('<a href='+fileObj.filePath+'>'+fileObj.name+'</a><br>');
     $("#firstUpload").remove();

     }
      }); }); 
      </script>

did you notice that i am using the exact same function and i am just changing the div name, ain't that ridiculous ? now i want my jquery function to accept two div parameters. can i do that?

thank you..

2 Answers 2

28

Combine the two selectors, just like in CSS:

$(document).ready(function() {
    $('#fileUpload, #fileUpload2').uploadify({ 
        ...
    });
});
Sign up to request clarification or add additional context in comments.

1 Comment

hehe, i was checking like. $('#fileUpload', #fileUpload2').uploadify({ i was putting an extra single quote there. thank you.
3
<script type="text/javascript">
$(document).ready(function() {
    $('#fileUpload,#fileUpload2').uploadify({ 
      'uploader': 'img/uploadify.swf',
      'script': 'uploadify.php',
      'folder': 'upload',
      'auto' : 'true',
      'cancelImg': 'img/cancel.png',
          'fileDesc': 'jpg/jpeg',
      'displayData': 'percentage',
      'fileExt': "*.jpg;*.jpeg",
      'sizeLimit' : '8388608',
      'fileDataName' : 'file',
      onComplete: function(event, queueID, fileObj, reposnse, data) {
        $('#filesUploaded').append('<a href='+fileObj.filePath+'>'+fileObj.name+'</a><br>');
        $("#firstUpload").remove();
      }
    }); }); 
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.