简体   繁体   English

简单的Java语言数学

[英]Simple Javascript Math

I am trying to perform the very simple task of doing simple multiplication below. 我正在尝试执行以下简单乘法的非常简单的任务。 I cannot get the input field to participate in the code below. 我无法获得输入字段来参与下面的代码。 Please let me know how I might be able to get this to work. 请让我知道我如何能够使它工作。 Thank you all! 谢谢你们!

<!DOCTYPE html>
<html>
<body>

<?php
$count="20";
?>
<input id="spend">
<button onclick="myFunction()">Calculate</button>

<p id="demo"></p>

<script>
function myFunction()
{
y=<?php echo "$count"; ?>;
z=document.getElementById('spend').innerHTML;
x=y+z;
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>

Hi try this code it's working 嗨,尝试此代码,它可以正常工作

<!DOCTYPE html>
<html>
<body>

<?php
$count=20;
?>
<input id="spend">
<button onclick="myFunction()">Calculate</button>

<p id="demo"></p>

<script>
function myFunction()
{
var y=<?php echo $count; ?>;
var z=document.getElementById('spend').value;
var x=y*z;
document.getElementById("demo").innerHTML=x;
}
</script>

</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM