-6

For example i have a variable

var test = "done";

how can I send it to php? and then post it

1 Answers1

0

try with this code

<script>
 var test = "done";
 document.getElementById('sample').value = test;
</script>

<form method = "post">
   <input type="hidden" id="sample" name="stext">
   <input type="submit" name="submit" value="submit">
</form>

<?php
 echo $_POST['stext'];
?>
sree
  • 389
  • 5
  • 17