本文介绍了OnClientClick Javascript:确认是否在文本框中获得价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我似乎找不到任何方法.我希望能够在文本(确认)框中使用BuyOutPrice的值,但似乎无法使其正常工作.
So I can't seem to find anywhere how to do this. I want to be able to use the value of BuyOutPrice in the text(confirm) box but can't seem to make it work.
更具体地说,我应该怎么写这部分:(您确定要以$ + BuyOutPrice +'?买断)
More specificly, how am I supposed to write this part:('Are you sure you want to buy-out for $' + BuyOutPrice + '?')
这只是我根据其他编程语言经验得出的最接近的猜测,但在JavaScript中似乎无效.
This was just my closest guess from experience in other programming languages but it appears invalid in JavaScript.
var BuyOutPrice = '<%= Content.ComparisonPrice %>';
<asp:ImageButton ID="BuyNowButton" OnClick="BuyNowButton_Click" Style="vertical-align:top;" ImageUrl="Images/btn_buyNow.png" runat="server" OnClientClick="javascript:return confirm('Are you sure you want to buy-out for $' + BuyOutPrice + '?'); BuyNow(); return ValidateBuyNow();" />
推荐答案
如果ComparisonPrice
是TextBox,请尝试以下操作:
If ComparisonPrice
is a TextBox so try this:
<asp:TextBox ID="ComparisonPrice" runat="server"></asp:TextBox>
<asp:ImageButton ID="BuyNowButton" Style="vertical-align:top;" ImageUrl="Images/btn_buyNow.png" runat="server" OnClientClick="javascript:return confirm('Are you sure you want to buy-out for' + momo() + '?'); BuyNow(); return ValidateBuyNow();" />
和JavaScript:
And JavaScript:
<script>
function momo() {
return document.getElementById('<%= ComparisonPrice.ClientID %>').value
}
</script>
这篇关于OnClientClick Javascript:确认是否在文本框中获得价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!