-1
I have a screen where there are several input type="file"
and I’m trying to make an icon appear when the user loads a file, making it easier to see that that input is already with a file.
Below follows the images of what I want, to facilitate understanding:
After choosing the file: This is my HTML:
<div class="row row-space ">
<div class="custom-file ">
<div class="row row-space ">
<input type="file" class="custom-file-input col-sm-11" id="ficha_inscricao" >
<label class="custom-file-label col-sm-11" for="ficha_inscricao">Escolha o Arquivo</label>
<i hidden class="fas fa-check fa-2x" style="color:green" id="ficha_inscricao_ok" ></i>
</div>
<small class="form-text text-muted ">Ficha de Inscrição Preenchida e Assinada.</small>
</div>
</div>
This is the script I’m using, in it I load the name of the selected file in input(this is working) and try to remove the hidden
that’s on my icon and that’s what I can’t do.
document.querySelector('.custom-file-input').addEventListener('change',function(e){
var fileName = document.getElementById("ficha_inscricao").files[0].name;
var nextSibling = e.target.nextElementSibling
nextSibling.innerText = fileName;
document.getElementsByTagName('ficha_inscricao_ok').removeAttribute("hidden");
})
In this example I am trying to do two things in the same function, but I have tried to do also in separate functions and the same way did not work.
Thank you very much, for the clarification I did not notice that I was using the getelementsbytagname, it worked perfectly!
– Marcos Rodrigues