<asp:TextBox ID="txtCosttotal" Text="10" runat="server"></asp:TextBox>
这是我的javascript代码
<script>
function GetValue() {
var result = document.getElementById('<%=txtCosttotal.ClientID%>');
alert("Your Total Cost is " + result);
}
</script>
我的vb代码txtitemcost和requestedqty值来自数据库
Dim icost2 As Double = 0
icost2 = Val(txtItemCost.Text) * Val(Txtrequestedqty.Text)
txtCosttotal.Text = icost2
ScriptManager.RegisterStartupScript(Me, [GetType](), "displayalertmessage", "GetValue();", True)
输出
“您的总费用是[对象HTMLinputElement]”
答案 0 :(得分:1)
您的函数document.getElementById('<%=txtItemNumber.ClientID%>')
会返回实际的input
元素。如果要获得实际值,则需要使用属性value
:
function GetValue() {
var result = document.getElementById('<%=txtItemNumber.ClientID%>').value;
alert("Your Total Cost is " + result);
}
您可以阅读有关value
property