Why javascript IF only works one time?
- by Emily
I have javascript code which copy the value of input file and past it in the text box in real time.
<script>
function copyit(){
var thephoto=document.getElementById('thephoto').value;
var fileonchange=document.getElementById('fileonchange').value;
if(!thephoto==fileonchange){
document.getElementById('fileonchange').value=thephoto;
}
}
window.setInterval("copyit()", 500);
</script>
Choose File : <input type="file" id="thephoto"><br>
Here Is the file name : <input type="text" id="fileonchange">
Sadly this only works one time and then stops pasting the value when changing the file again. ( i mean you should reload the page to works again)
Is IF has a cache or something? you can try the code by yourself to see.
Thank you all