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>
複製代碼 |