![](/img/trans.png)
[英]How do I add the total of these text boxes made in HTML and display in another textbox?
[英]How do I display text above after submitting it into a textbox HTML
解決這種情況的最佳方法是使用Javascript或jQuery,這本身就是javascript的庫。 讓我向您展示如何在jQuery中進行操作
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> <script> $(document).ready(function(){ $("#form-to-be-submitted").click(function(){ $(".whatever-styling-you-want").html($("#textBox").val()); }); }); </script> <div class="whatever-styling-you-want"> </div> <!-- Your text box and submit button --> <div> <input type="text" id="textBox" placeholder="Please input your text here..."/> <input id="form-to-be-submitted" value="submit" type="button"/> </div>
JavaScript的方式也相同。 無需使用click函數,而是將JavaScript的on函數與'click'事件一起使用。 我希望這有幫助。
<!DOCTYPE HTML>
<html>
<head>
<style>
</style>
</head>
<body>
<p id="x"></p><br>
<input id="value"><input type="button" value="submit" onClick="getV()">
<script>
function getV(){document.getElementById("x").innerHTML = document.getElementById("value").value;}
</script>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.