So I’m a novice coder and have been trying to piece together a (seemingly) simple function. I want the user to be able to enter in a certain amount of time into a form, and then when they click submit, it opens a new page and closes after that amount of time.
There is a very simple form on the first page that accepts input and looks like so:
<form action=”onbreak.php” target=”_blank” method=”POST”><p class=”fillable”>I would like to view <input type=”text” name=”url” id=”url” value=”” size=”30″/> for <input type=”text” name=”timeinput” id=”timeinput” value=”” size=”3″/> minute(s). <input type=”submit” value=”Break Me!”/></p></form>
This is in the head of the second page which should be retrieving the data:
<?php $_POST[‘timeinput’] = timeinput; ?>
<script>
var howLong = <?php echo timeinput; ?>;
function closeWindow(){
setTimeout(“alert(howLong);”,2000);
// setTimeout(“self.close();”,howLong);
}
</script>
The “alert(howLong);” is so I get some instant feedback when it works. The commented out line is how the script should actually function. Any help would be much appreciated!