2
I have two inputs that both have an id, and I have a button with an oncick event attached (directly in HTML) that takes the value of both input fields, now I intend to separate the javascript in a separate file but I cannot link the javascript function, below everything docked 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) this way does not work:
window.onload = function(){
var btnEnviaImg = document.getElementById("btnEnviaImg");
btnEnviaImg.addEventListener("click",exibeImagem(imgPC.value, imgWEB.value),false);
}
,Oeslei has not yet worked, thought it has to do with the fact that it is passing as parameters the values of two inputs.
– Ricardo
@Ricardohenrique The function
exibeImagem
is being called? Add an alert at the beginning of it to check.– Oeslei