Extjs 常见问题:如何提交combobox的值

转至:http://apps.hi.baidu.com/share/detail/5452956

//提交出去的是显示域,而不是值域
//解决很简单,使用hiddenName即可。

examples/my/test_combobox.html

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>my test</title>
    <link rel="stylesheet" type="text/css" href="../../../resources/css/ext-all.css" />
    <script type="text/javascript" src="../../adapter/ext/ext-base.js"> </script>
    <script type="text/javascript" src="../../ext-all-debug.js"> </script>

    <script type="text/javascript">
Ext.onReady(function(){
    Ext.QuickTips.init();
    Ext.form.Field.prototype.msgTarget = 'side';

    var sl = [[1,'10'],[2,'100'],[3,'500'],[4,'1000'],[5,'5000']];
    var store3 = new Ext.data.SimpleStore({
                    fields:["code3",'name3'],
                    data:sl
                });
    var simples = new Ext.FormPanel({
                    baseCls:'x-plain',
                    iconCls : 'icon-info',   
                    bodyStyle:'padding:10px',
            items: [{
                     xtype:'fieldset',
                     title: '必填项',
                    bodyStyle:'padding:5px',
                     autoHeight:true,
                    labelWidth:60,
                     defaults: {readOnly:true,typeAhead:true,allowBlank:false,anchor:'95%',mode:'local',selectOnFocus:true,triggerAction:'all'},
                    defaultType: 'combo',
                            items:[
                            {
                                fieldLabel:"数 量",
                                name:"number",
                                displayField:"name3",
                                valueField:"code3",
                                hiddenName:'number',
                                store:store3,
                                mode:'local',
                                blankText:'数量不能为空'
                            }]
                    }]
                });
                    var win = new Ext.Window({
                        id:'win',
                        layout:'fit',
                        iconCls : 'icon-info',                       
                        width: 470,
                        height: 280,
                        plain: true,
                        bodyStyle:'padding:5px;',
                        closable:true,
                        collapsible:true,
                        items:simples,
                        buttons: [{
                               text: '生 成',
                            type: 'submit',
                                handler:function(){
                                  if(simples.form.isValid()){
                                      Ext.MessageBox.show({
                                           title: '请稍等',
                                           msg: '正在加载...',
                                           progressText: '',
                                           width:400,
                                           progress:true,
                                           closable:false,
                                           animEl: 'loding'
                                       });

                                    simples.form.doAction('submit',{
                                        url:'post.php',//文件路径
                                        method:'post',
                                        params:'',
                                        success:function(form,action){
                                                if (action.result.msg=='ok') {
                                                    Ext.Msg.alert('提交成功',action.result.msg);
                                                    win.close();
                                                } else {
                                                    Ext.Msg.alert('提交失败',action.result.msg);
                                                }
                                        },
                                        failure:function(form,action){
                                                Ext.Msg.alert('错误','服务器出现错误请稍后再试!');
                                        }
                                    });
                                   }                                                         
                                }
                           },{text: '重 置',handler:function(){simples.form.reset();}}
                        ]
                    });
        win.show();
})
    </script>

</head>
<body>

</body>
</html>
补充:

在你的Combobox有id的时候千万不要和hiddenName一样,否则数据不能显示,而数据可以正确返回.这个时候错误很难找.


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值