You are on page 1of 3

<html>

<head>

<title>Contar</title>

</head>

<body>

<form id='form' method="POST">

<input type="number" width="20px" heigth="15px" name="valor">

<input type='submit' id='btn' value="Enviar">

</form>

<div id="resultado">

Valor do FizzBuzz:

<?php

$valor = $_POST['valor'];

if (isset($valor)){

return FizzBuzz($valor);

} else {

echo "<h3>Digite algum valor</h3>";

?>

</div>

<script>

const resultado = document.getElementById("resultado")

const btn = document.getElementById("btn")

const form = document.getElementByid('form')


btn.addEventListener('submit', function(){

form.addEventListener('submit', function(e){

e.preventDeafult;

})

})

</script>

</body>

</html>

<?php

function FizzBuzz($n){

$arr = array();

for($i = 1; $i <= $n; $i++){

if($i % 3 == 0 && $i % 5 == 0){

$arr[] = 'FizzBuzz';

} else if ( $i % 3 == 0){

$arr[]='Fizz';

} else if ( $i % 5 == 0){

$arr[]= 'Buzz';

} else {

$arr[]= $i;

}
echo $arr[$i-1]." ";

?>

You might also like