我有(工作):第一頁 - 用戶輸入字符串並按提交按鈕。此參數通過會話發送到運行某種腳本命令並顯示結果(輸出)的其他頁面。這裏的代碼,使之更加明確:php javascript刷新頁面
第一頁:
<?php
session_start();
echo "<input type=\"text\" id=\"userInput\">";
echo "<br><button onclick=\"submit()\">Submit</button>";
$_SESSION[''] = $input;
?>
<script type="text/javascript">
var submit = function() {
input = document.getElementById("userInput").value;
window.open ('secondPage.php?userInput=' + input,'_self',false);}
</script>
第二頁:
<?php
session_start();
$input = $_GET['userInput'];
$command = "./myScript.py $input";
system($command, $retval);
?>
現在,我想有兩個在一個單一頁面,即當頁面打開時,輸入字段和按鈕將位於頂部,在它下面將是第二頁命令的輸出,每當用戶「提交」另一個輸入時(第一次userInput將爲空),刷新該輸入字段和按鈕。希望很明顯,或多或少。任何幫助?
那麼你爲什麼不嘗試和代碼的東西做 – RiggsFolly
似乎會有小點提交頁面,你可以做一切與一些JavaScript並沒有頁面提交 – RiggsFolly
你可能會更具體嗎? – user1418018