一、簡單例子:
- <mce:script language="javascript" type="text/javascript"><!--
- function toSettlement() {
- Ext.Msg.prompt("標題", "消息提示", function (btn, text) {
- if (btn = "ok") {
- alert("你輸入的值爲" + text);
- }
- })
- }
-
- // --></mce:script>
效果: javascript
點擊肯定後: java
二、複雜的使用,咱們可爲prompt調定默認值,指定prompt的輸入輸是單行仍是多行,示例:
- <mce:script language="javascript" type="text/javascript"><!--
- function toSettlement() {
- var signAmount = Ext.getCmp("SignAmount").getText();
- var changeTotalCount = Ext.getCmp("ChangeTotalCount").getValue();
- var changeTotalAmount = Ext.getCmp("ChangeTotalAmount").getValue();
-
- var msgTemplate = "<div class=/"box order-dashboard/" style="/" mce_style="/""margin-bottom: 5px;/">"
- + "<div class=/"bd/">"
- + "<div class=/"trade-status/">"
- + "<b style="/" mce_style="/""font-size: 12px; color:orange;/">當前項目</b><br />"
- + "<hr />"
- + "<table border=/"0/" cellspacing=/"0/" cellpadding=/"0/" class=/"myTable/">"
- + "<tr>"
- + "<td style="/" mce_style="/""width: 30%/">"
- + "簽定金額:{0}</td>"
- + "<td style="/" mce_style="/""width: 30%/">"
- + "項目共變動{1}次"
- + "</td>"
- + "<td>"
- + "變動成本爲{2}:"
- + "</td>"
- + "</tr></table>"
- + "</div></div></div><br/>"
- + "請輸入當前項目的結算金額:";
- Ext.Msg.prompt("結算項目", String.format(msgTemplate, signAmount, changeTotalCount, changeTotalAmount), function (btn, text) {
- //........
- }, this, false, "10000");
- }
-
- --></mce:script>
此例經過帶HTML標籤的字符串顯示更好的消息提示,並設定默認值爲1000,效果圖: app
說明: this
- Ext.Msg.prompt("結算項目", String.format(msgTemplate, signAmount, changeTotalCount, changeTotalAmount), function (btn, text) {
- //........
- }, this, false, "10000");
第5個參數設置爲true,則輸入框爲多行,最後參數即爲指定默認值。 spa