標題:
php or javascript process
[打印本頁]
作者:
ray
時間:
2020-9-5 11:02
標題:
php or javascript process
<?php
$c = 0;
if(isset($_POST["a"]) && $_POST["a"] != "" && isset($_POST["b"]) && $_POST["b"] != "")
{
$c = $_POST["a"] + $_POST["b"];
}
?>
<html>
<form action="test.php" method="post">
<input type="text" id="a" name="a">
<input type="text" id="b" name="b">
<input type="text" name="d">
<input type="button" value="+(JS)" onclick="add()">
<input type="submit" value="+(php)">
</form>
<div id="result"><?php echo($c)?></div>
</html>
<script
src="https://code.jquery.com/jquery-3.5.1.js"
integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
crossorigin="anonymous"></script>
<script>
function add()
{
$("#result").html(parseInt($("#a").val())+parseInt($("#b").val()));
}
</script>
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2