I have been trying to pass javascript variable to php and it wont work dynamically, but works statically.
here is the dynamic code that does not work:
<input onClick="myFunction();" id="demoteTask" name="demoteTask" type="checkbox"/>Demote to Child
<script>
function myFunction() {
var parent = prompt("Please enter parent reskb id:", "");
<?php $new = "<script>document.writeln(parent);</script>" ?>
alert (<?php $new ?>);
}
</script>
here is the static code that worked:
<script>
var p1 = "hello";
</script>
<?php
$kk="<script>document.writeln(p1);</script>";
echo $kk;
?>
The dynamic code returns me null value in the alertbox.