views:

34

answers:

1

This is my Html code and I'm trying to pass my id(test1) to fileUp function. It only works when I type 'test1' and stops working when I'm trying to pass a variable. Please let me know if there is a way to overcome this problem.

<a id='test1' href="#" onclick="fileUp(1, 'test1')">Upload Your file</a>

function fileUp(id,nameTest){
    var test=nameTest;

    new AjaxUpload(nameTest , {
        action: 'upload-test.php',
        onComplete: function(file, response){                        
            alert(response);
        }
    });
};
+2  A: 

What do you mean "it doesn't work"?

<a id='test1' href="#" onclick="fileUp(1, this.id)">Upload Your file</a>

In jQuery:

$('#test1').bind('click', function (evt) {
    fileUp(1, $(this).attr('id'));

    evt.preventDefault();
});
Matt