I'm trying to call a javascript function on a button in html. Both the button and the javascript function are in the same file, however I am having an error saying that the function is not available.
HTML:
<button onclick="countFiles()">Desencriptar</button>
Javascript:
<script>
function countFiles() {
$directory = "/uploadFiles";
$filecount = 0;
$files = glob($directory . "*");
if ($files){
$filecount = count($files);
}
if($filecount > 0){
echo '<script type="text/javascript">',
'window.location.href = "decrypt.php";',
'</script>';
}else{
echo "<script type='text/javascript'>alert('Precisa de inserir pelo menos 1 ficheiro');</script>";
}
}
</script>
Aucun commentaire:
Enregistrer un commentaire