5

我有一个生成表单面板的脚本:

var form = new Ext.FormPanel({
    id: 'form-exploit-zombie-' + zombie_ip,
    formId: 'form-exploit-zombie-' + zombie_ip,
    border: false,
    labelWidth: 75,
    formBind: true,
    defaultType: 'textfield',
    url: '/ui/modules/exploit/new',
    autoHeight: true,
    buttons: [{
        text: 'Execute exploit',
        handler: function () {
            var form = Ext.getCmp('form-exploit-zombie-' + zombie_ip);

            form.getForm().submit({
                waitMsg: 'Running exploit ...',
                success: function () {
                    Ext.beef.msg('Yeh!', 'Exploit sent to the zombie.')
                },
                failure: function () {
                    Ext.beef.msg('Ehhh!', 'An error occured while trying to send the exploit.')
                }
            });
        }
    }]
});

然后,相同的脚本从我的服务器中检索一个 json 文件,该文件定义了该表单应包含的输入字段的数量。然后脚本将这些字段添加到表单中:

Ext.each(inputs, function(input) {
    var input_name;
    var input_type = 'TextField';
    var input_definition = new Array();

    if(typeof input == 'string') {
        input_name = input;
        var field = new Ext.form.TextField({
                id: 'form-zombie-'+zombie_ip+'-field-'+input_name,
                fieldLabel: input_name,
                name: 'txt_'+input_name,
                width: 175,
                allowBlank:false
            });
        form.add(field);
    }
    else if(typeof input == 'object') {
        //input_name = array_key(input);

        for(definition in input) {
            if(typeof definition == 'string') {

            }
        }
    } else {
        return;
    }
});

最后,表单被添加到我界面的相应面板中:

panel.add(form);
panel.doLayout();

我遇到的问题是:当我通过单击按钮提交表单时,发送到我的服务器的 http 请求不包含添加到表单的字段。换句话说,我不会将这些字段发布到服务器。

任何人都知道为什么以及如何解决这个问题?

4

2 回答 2

9

你的问题在这里:

id: 'form-exploit-zombie-'+zombie_ip,
formId: 'form-exploit-zombie-'+zombie_ip,

您正在做的是将表单面板的 id 属性和表单(表单标签)的 id 属性设置为相同的值。这意味着您有两个具有相同 id 的元素,这是错误的。

只需删除此行

formId: 'form-exploit-zombie-'+zombie_ip,

你应该没事。

于 2010-05-21T08:47:12.450 回答
0

您是否检查了表单值的 HTTP 请求参数?

如果您的服务器端在 PHP 中,您通过传递任何字段名称从响应中得到什么?例如,如果您的输入名称之一是“xyz”,您会得到什么

$_POST[ 'txt_xyz' ]
于 2010-05-21T07:26:15.597 回答