![](/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.