Reputation: 37
Ok I want my file upload button to change a span I have to make the user aware the file HAS been selected.
<script type="text/javascript">
function get_filename(obj,fileupid) {
var file = obj.value;
var disploc = fileupid.value;
document.getElementById('current_file_' + disploc).innerHTML='Attached: ' + file;
}
</script>
...
<input type="file" id="file-503" onchange="get_filename(this,'file-503');" /> <span id="current_file_file-503"> </span>
Can anyone see a problem with this code? The actual input and span IDs are variable but this is how they are being output in this case.
If I enter the innerHTML change directly into the address bar or scratchpad (putting 'file-503' in place of disploc and just using 'test' as the innerHTML output of course), then it works.. But in actual use, nothing happens..
I've been racking my brains for literally hours now and nothing is making sense.
Please help!!
Upvotes: 0
Views: 946