开发者

How to multiply and set multiply value on textbox using JavaScript

Work on ASP.net vs 05 C#,There are three textBox.Length,Height,Sft.I want to multiply Length*Height and want to put value on Sft text.

  <asp:TextBox ID="txtLength" runat="server"></asp:TextBox>
                <asp:TextBox ID="txt开发者_JAVA技巧Height" runat="server" onblar="javascript:ComputeSft(  );" ></asp:TextBox>
                <asp:TextBox ID="txtSft" runat="server"></asp:TextBox></td>



Sft=Length*Height.

function ComputeSft()
{
   var _nLength, _nHeight,_nSft;
    _nLength=document.getElementById("txtLength").innerText;
    _nHeight=document.getElementById("txtHeight").innerText;
    _nSft=_nLength*_nHeight;
    alert(_nSft);
    txtSft.Text=_nSft;
}

How to multiply? and How to set multiply value on textbox?


I believe what you are looking for is the value property.

Try this:

function ComputeSft()
{
    var _nLength = document.getElementById("txtLength").value;
    var _nHeight = document.getElementById("txtHeight").value;
    var _nSft = _nLength * _nHeight;
    alert(_nSft);
    document.getElementById("txtSft").value = _nSft;
}


The code you have written is a javascript there is no innerText in javascript use value instead

var txtSft=document.getElementById('<id of sfttext>');
txtSft.value=_nSft;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜