开发者

Show content of two textboxes in a third textbox in real time

I have 2 textboxes: Box1 an开发者_运维技巧d Box2.

Using JavaScript I would like a third box to show: "ContentOfBox1 metre x ContentOfBox2 metre" in real time.


Place an onchange event on both your text boxes like so

<input id="text1" onchange="modifyText3" />
<input id="text2" onchange="modifyText3" />
<input id="text3" />

Then your javascript would be

function modifyText3()
{
    var val1 = document.getElementById("text1").value;
    var val2 = document.getElementById("text2").value;
    document.getElementById("text3").value = val1 + " meter x " + val2 + " meter";
}

Hope this helps.


Create 3 text boxes and add js function "changeOutput" on onChange event of 2 input boxes.

<input id="input1" onchange="changeOutput()" value="" />
<input id="input2" onchange="changeOutput()" value="" />
<input id="output" value=""/>

And the javascript function is

function changeOutput(){
    var input1 = document.getElementById("input1").value;
    var input2 = document.getElementById("input2").value;
    document.getElementById("output").value = val1 + " metre x " + val2 + " metre";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜