[英]JavaScript is not printing my HTML
I have this function: 我有这个功能:
function suggestSell() {
var sellValue = document.getElementById('sellValue');
var btcVol = document.getElementById('btcVol');
var grossSell = btcVol * sellValue ;
var sellFee = grossSell * .006;
var sellOff = grossSell - sellFee;
document.write('<p>sellValue: ' + sellValue.innerHTML +
'<br> btcVol: ' + btcVol.innerHTML +
'<br> grossSell: ' + grossSell +
'<br> sellFee: ' + sellFee +
'<br> sellOff: ' + sellOff +
'<br></p>');
}
that i call like this: 我称之为:
<script>suggestSell();</script>
But it displays this in the browser. 但它会在浏览器中显示。
1156.161.42053359undefinedundefinedundefined
1156.161.42053359undefinedundefinedundefined
var sellValue = document.getElementById('sellValue');
selects the node. 选择节点。 You probably need the
value
你可能需要这个
value
var sellValue = document.getElementById('sellValue').value;
Same thing for btcVol
btcVol
var btcVol = document.getElementById('btcVol').value;
If you do make this change, note that sellValue.innerHTML
and btcVol.innerHTML
should be changed appropriately. 如果您确实进行了此更改,请注意应该适当更改
sellValue.innerHTML
和btcVol.innerHTML
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.