如何将文本框中的输入值添加到一起,然后用javascript显示在另一个文本框中?

如何将文本框中的输入值添加到一起,然后用javascript显示在另一个文本框中?,javascript,html,Javascript,Html,我在将文本框中的输入值添加到一起并显示在另一个文本框中时遇到问题。我对平台和编码非常陌生,请不要认为我很笨。 以下是我的html代码: <form name="practise" onsubmit="return performOp()" method="post"> <p>Lettuce $2.00 Ea</p> <input type="text" name="

我在将文本框中的输入值添加到一起并显示在另一个文本框中时遇到问题。我对平台和编码非常陌生,请不要认为我很笨。 以下是我的html代码:

<form name="practise" onsubmit="return performOp()" method="post">
<p>Lettuce $2.00 Ea</p>
<input type="text" name="number" id="Lettuce" placeholder="Input Lettuce Amount">
<p>Eggplants $4.99 Ea</p>
<input type="text"  name="number" id="Eggplants" placeholder="Input Eggplants Amount">
<p>Pepper $8.29 per bag (4 pieces)</p>
<input type="text"  name="number" id="Pepper" placeholder="Input Pepper Amount">
<p>Cauliflowers $3.99 Ea</p>
<input type="text" name="number" id="Cauliflowers" placeholder="Input Cauliflowers Amount">
<p>Bananas $2.79/KG</p>
<input type="text"name="number" id="Bananas" placeholder="Input Bananas Amount">
<p>Apples $3.89/KG</p>
<input type="text"  name="number" id="Apples" placeholder="Input Apples Amount">
<p>Avocados $1.89 Ea</p>
<input type="text"  name="number" id="Avocados" placeholder="Input Avocados Amount">
<p>Tomoatoes $8.99/KG</p>
<input type="text"  name="number" id="Tomatoes" placeholder="Input Tomoatoes Amount">
You have chosen a total of: <input name="total" id="total">
<input type="submit">
</form>
我不知道我做错了什么,有人能帮我吗


谢谢

您需要进一步了解HTML页面的工作方式。您尚未执行任何操作来触发调用函数
performOp()
。请研究当用户单击
submit
按钮时如何调用
performOp()
函数,因为这将清除一些基础知识。
function performOp(){
    var a = parseInt(document.getElementById("Lettuce").value)
        a.value="2";
    var b = parseInt(document.getElementById("Eggplants").value);
            b.value = "4.99";
    var c = parseInt(document.getElementById("Pepper").value);
            c.value = "8.29";
    var d = parseInt(document.getElementById("Cauliflowers").value);
            d.value = "3.99";
    var e = parseInt(document.getElementById("Bananas").value);
            e.value = "2.79";
    var f = parseInt(document.getElementById("Apples").value);
            f.value = "3.89";
    var g = parseInt(document.getElementById("Avocados").value);
            g.value = "1.89";
    var h = parseInt(document.getElementById("Tomoatoes").value);
            h.value = "8.99";
    
    var result=a*2+b*4.99+c*8.29+d*3.99+e*2.79+f*3.89+g*1.89+h*8.99;
        document.getElementByName("number").value = result;
        }