Ext.Msg.prompt的高级应用

转自:http://blog.csdn.net/llxchen/article/details/6575555

 

1、简单例子:

 

[javascript] view plaincopy

  1.   <mce:script language="javascript" type="text/javascript"><!--  
  2.         function toSettlement() {  
  3.             Ext.Msg.prompt("标题", "消息提示", function (btn, text) {  
  4.                 if (btn = "ok") {  
  5.                     alert("你输入的值为" + text);  
  6.                 }  
  7.             })  
  8.         }  
  9.       
  10. // --></mce:script>  

 

 

效果:

点击确定后:

 

2、复杂的使用,我们可为prompt调定默认值,指定prompt的输入输是单行还是多行,示例:

 

[c-sharp] view plaincopy

  1. <mce:script language="javascript" type="text/javascript"><!--  
  2.      function toSettlement() {  
  3.          var signAmount = Ext.getCmp("SignAmount").getText();  
  4.          var changeTotalCount = Ext.getCmp("ChangeTotalCount").getValue();  
  5.          var changeTotalAmount = Ext.getCmp("ChangeTotalAmount").getValue();  
  6.   
  7.          var msgTemplate = "<div class=/"box order-dashboard/" style="/" mce_style="/""margin-bottom: 5px;/">"  
  8.                              + "<div class=/"bd/">"  
  9.                              + "<div class=/"trade-status/">"  
  10.                              + "<b style="/" mce_style="/""font-size: 12px; color:orange;/">当前项目</b><br />"  
  11.                              + "<hr />"  
  12.                                  + "<table border=/"0/" cellspacing=/"0/" cellpadding=/"0/" class=/"myTable/">"  
  13.                                  + "<tr>"  
  14.                                  + "<td style="/" mce_style="/""width: 30%/">"  
  15.                                  + "签订金额:{0}</td>"  
  16.                                  + "<td style="/" mce_style="/""width: 30%/">"  
  17.                                                     + "项目共变更{1}次"  
  18.                                                  + "</td>"  
  19.                                                  + "<td>"  
  20.                                                   + "变更成本为{2}:"  
  21.                                                  + "</td>"  
  22.                                  + "</tr></table>"  
  23.                                  + "</div></div></div><br/>"  
  24.                                  + "请输入当前项目的结算金额:";  
  25.          Ext.Msg.prompt("结算项目", String.format(msgTemplate, signAmount, changeTotalCount, changeTotalAmount), function (btn, text) {  
  26.          //........  
  27.          }, this, false, "10000");  
  28.      }  
  29.    
  30. --></mce:script>  

 

 

此例通过带HTML标签的字符串显示更好的消息提示,并设定默认值为1000,效果图:

 

 

说明:

 

[javascript] view plaincopy

  1. Ext.Msg.prompt("结算项目", String.format(msgTemplate, signAmount, changeTotalCount, changeTotalAmount), function (btn, text) {  
  2.          //........  
  3.          }, this, false, "10000");  

 

第5个参数设置为true,则输入框为多行,最后参数即为指定默认值。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值