Reputation: 371
I am using simple ajax uploader
https://github.com/LPology/Simple-Ajax-Uploader
https://www.lpology.com/code/ajaxuploader/docs.php
my file upload button
<div class="form-group">
<input type="button" id="upload-btn1" class="btn btn-success clearfix" value="Choose file">
</div>
I am trying to use onChange callback function of SimpleAjax Uploader
onChange( filename, extension, uploadBtn )
This Function is called when user selects a file.
The function gets passed three arguments:
I am facing problem with 3rd parameter of onChange
function uploadBtn
which is button reference it can be different digits, so I wonder how can I use this reference to change my upload button text when file is selected!
Thanks.
Upvotes: 2
Views: 102
Reputation: 126
This is actually a bug in simple ajax uploader.
For more info please see issue #115
Upvotes: 1
Reputation: 9262
I don't know the "SimpleAjax Uploader" library, but typical jQuery callbacks return a DOM element, rather than a wrapped set. Therefore, you should be able to change the displayed text of the button by converting it to a jQuery wrapped set and using the val()
method. In the sample below, uploadBtn
is a DOM element. The anchor tag's click
handler wraps it and uses val()
to change the text after each click.
var uploadBtn = document.getElementById('uploadBtn');
$('a').click(function() {
var d = new Date();
$(uploadBtn).val("Changed at " + d);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<input id="uploadBtn" type="button" value="Default text" />
<br/>
<a href="#">Change the text of the button</a>
In your case, you'd have an onchange
callback like:
function onchange( filename, extension, uploadBtn ) {
$(uploadBtn).val("New text goes here");
}
Upvotes: 1