現在我已經編程在PHP中,每擊中一個按鈕後,你做,但多數民衆贊成在PHP中,所以在點擊按鈕後,程序與接觸服務器。 我想知道是否有可能通過javascrit使命中計算sothat程序不升級到服務器的命中將在屏幕上可見,並通過JavaScript每次升級。在結束洞之後,我可以將結果保存到服務器。 我做了以下測試。但電腦仍然通過服務器進行更新。即時製作一個高爾夫記分卡程序在PHP中,但要使用JavaScript來計數點擊
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<?
if ($aantalslagen_plus==""){
$aantalslagen_plus="0";
}
?>
<script type="text/javascript">
var a = <? echo $aantalslagen_plus; ?>
function bereken() {
a += 1;
document.getElementById('aantalslagen').value = a;
};
</script>
</head>
<body>
<form method="post" action="" . $_SERVER['PHP_SELF'] . "">
<br><br><br>
<table width="422" height="179" border="0">
<tr>
<td>totaal aantal slagen: </td>
<td> </td>
</tr>
<?php
$aantalslagen_plus = htmlentities($_POST['aantalslagen_plus']);
?>
<tr>
<td>totaal aantal slagen php:</td>
<td>
<? echo "<input type=\"text\" VALUE=\"$aantalslagen_plus\" name=\"aantalslagen_plus\" id=\"aantalslagen\" size=\"10\">"; ?>
<td><? echo $aantalslagen_plus; ?></td>
</tr>
</table>
<br>
<button onclick="bereken();"> + </button>
</form>
</body>
</html>
是的,那是可能的。我假設你知道PHP需要一個web服務器來執行。如果你想要一個不需要與服務器交互的網頁來運行(一旦它被加載),你就不能使用PHP。 你可能想看看你正在計劃的「localstorage」。 – Burki