I tried to create a timer based on the user input for how long the timer will go
here is my code for user input userinput.html
<form method="post" action="update.php">
<input type="number" name="inputnumber" />
<input type="submit" value="OK" />
</form>
here is my code using javascript and php update.php
<script type="text/javascript">
function countdown(secs, elem){
var element = document.getElementById(elem);
element.innerHTML = "Please wait for "+secs+" seconds";
secs--;
var timer = setTimeout('countdown('+secs+',"'+elem+'")', 1000);
}
</script>
</head>
<body>
<div id="status"></div>
<script type="text/javascript">
countdown("<?php $test = $_POST['inputnumber'];?>","status");
</script>
</body>
I'm trying to pass the user input using php to javascript which is from this line
<script type="text/javascript">
countdown("<?php $test = $_POST['inputnumber'];?>","status");
</script>
I want the timer start based on the user input
but the result is the timer always start from 0
is my code wrong to passing the value from php to javascript ??
anyone know how to pass the value??
thanks