gpt4 book ai didi

javascript - 实时 JavaScript 计算

转载 作者:行者123 更新时间:2023-11-28 18:16:35 25 4
gpt4 key购买 nike

我正在尝试根据表单字段的输入配置实时计算器。我的问题是,我根本不知道如何在网站上显示结果。

<label class="contactform-label" for="contactform-member"><span class="contact_form_span">Member*:</span> </label>
<input class="contactform-input" type="text" id="contactform-member" placeholder="Member" name="member" value="" />
<span id="member-kosten">
<script type="text/javascript">document.write(ausgabe)</script>
</span>



var price = 90;
var member = document.getElementById("contactform-member").value;
var calculate = Math.sqrt(price * member);
var ausgabe = (calculate);

最佳答案

使用此代码:

function fun(){
var price = 90;
var member = document.getElementById("contactform-member").value;
var calculate = Math.sqrt(price * member);
var ausgabe = (calculate);
document.getElementById("member-kosten").innerHTML = ausgabe;
}
<label class="contactform-label" for="contactform-member"><span class="contact_form_span">Member*:</span> </label>
<input class="contactform-input" type="text" id="contactform-member" placeholder="Member" name="member" value="" onkeyup="fun()" />
<span id="member-kosten">

</span>

关于javascript - 实时 JavaScript 计算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40676973/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com