0

When I select a date that I memorize in the selected variable, when I press the Submit button, I would like to print the value of the js variable in the php file. How can I do? At the time php returns indefinded index 'name'

Index File

<html>
<head>
<script type="text/javascript">

$( function() {

$('#datepicker').datepicker({
    dateFormat: 'dd-mm-yy',minDate:0 });


$("#datepicker").on("change",function(){
var selected = $(this).val();
$.get('Prenota.php', {getname: selected});

console.log(selected, "Hello, world!");
});
} );
</script>
</head>
<body>
<div id="datepicker"></div>
<form action ="Prenota.php" method="GET"> <input type="sumbit" name="upload" 
value ="Prenota">
</form>
</body>
</html>

PHP

<?php
 $variable = $_GET['name'];
 echo ($variable)
 ?>
bhadri
  • 28
  • 4
Vincenzo
  • 25
  • 4

0 Answers0