Home >Backend Development >PHP Tutorial >php 如何获取js的prompt里面的值

php 如何获取js的prompt里面的值

WBOY
WBOYOriginal
2016-06-23 13:53:341155browse

想用php 如何获取js的prompt里面的值,想着用隐藏表单来获取,可是不想设置提交按钮,要怎么提交数据,怎样改下面的代码,才能获取php 如何获取js的prompt里面的值,求解?
<script> <br /> var str=window.prompt('请输入修改主题', ''); <br /> document.getElemengById("content").value =str; <br /> </script>




$content=$_POST["content"];
echo $content;
?>


回复讨论(解决方案)

次序错了!
虽然可以这么写,但并无使用价值。因为提交将产生新的 document

<?phpif($_POST) {  $content=$_POST["content"];  echo $content;  exit;}?><form id="form" action="" method="post"><input type="hidden" name="content" id="content" value=""></form><script>var str=window.prompt('请输入修改主题', '');document.getElementById("content").value =str;document.getElementById("form").submit();</script

衷心地谢谢大神,问题解决了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn