[英]how can i put the value of textbox into alertmessegebox javascript
<asp:TextBox ID="txtCosttotal" Text="10" runat="server"></asp:TextBox>
this is my javascript code 这是我的JavaScript代码
<script>
function GetValue() {
var result = document.getElementById('<%=txtCosttotal.ClientID%>');
alert("Your Total Cost is " + result);
}
</script>
my vb code the txtitemcost and requestedqty the value is coming from database 我的VB代码txtitemcost和requestqty该值来自数据库
Dim icost2 As Double = 0
icost2 = Val(txtItemCost.Text) * Val(Txtrequestedqty.Text)
txtCosttotal.Text = icost2
ScriptManager.RegisterStartupScript(Me, [GetType](), "displayalertmessage", "GetValue();", True)
the output 输出
" Your Total Cost is [object HTMLinputElement] " “您的总费用是[object HTMLinputElement]”
Your function document.getElementById('<%=txtItemNumber.ClientID%>')
returns the actual input
element. 您的函数
document.getElementById('<%=txtItemNumber.ClientID%>')
返回实际的input
元素。 If you want to get to the actual value you need to use property value
: 如果要获得实际值,则需要使用属性
value
:
function GetValue() {
var result = document.getElementById('<%=txtItemNumber.ClientID%>').value;
alert("Your Total Cost is " + result);
}
You can read more about value
property 您可以阅读有关
value
属性的更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.