I have two inputs that both have an id, and I have a button with an oncick event bound (directly in HTML) that receives the value of both input fields as input, now I want to separate javascript into a separate file, but I can not make the javascript function link, below everything in the HTML file:
<input type="file" id="imgPC">
<input type="text" id="imgWEB">
<input type="button" onclick="exibeImagem(imgPC.value, imgWEB.value)" id="btnEnviaImg" value="Enviar"/>
<script type="text/javascript">
function exibeImagem(imgPCValue, imgWEBValue){
alert(imgPCValue);
alert(imgWEBValue);
}
</script>
As I did with the separate file (I removed the onclick from the input and put the method inside the separate file) so it does not work:
window.onload = function(){
var btnEnviaImg = document.getElementById("btnEnviaImg");
btnEnviaImg.addEventListener("click",exibeImagem(imgPC.value, imgWEB.value),false);
}