【问题标题】:Need to add select fields to MsgBox jquery需要将选择字段添加到 MsgBox jquery
【发布时间】:2011-05-19 03:44:04
【问题描述】:

我需要使用 jQuery 将选择字段添加到 MsgBox。有谁知道怎么做?

if (input.type == 'checkbox')
{
    iLabel = input.label ? '<label class="' + this.options.name + '-label">' : '';
    fLabel = input.label ? input.label + '</label>' : '';
    input.value = input.value === undefined ? '1' : input.value;
    iName  = input.name === undefined ? this.options.name + '-label-' + i : input.name;
    this.esqueleto.inputs.append($(iLabel + '<input type="' + input.type + 
        '" style="display: inline; width: auto;" name="' + iName + '" value="' + 
        input.value + '" autocomplete="off"/>' + fLabel));
}

我将其更改为选择字段,但在通信 PHP > jQuery 时它不起作用,反之亦然。 有人可以帮忙吗?

【问题讨论】:

    标签: jquery msgbox


    【解决方案1】:
    if (input.type == 'checkbox') {
        iLabel = input.label ? '<label class="' + this.options.name + '-label">': '';
        fLabel = input.label ? input.label + '</label>': '';
        input.value = input.value === undefined ? '1': input.value;
        iName = input.name === undefined ? this.options.name + '-label-' + i: input.name;
        this.esqueleto.inputs.append($(iLabel + '<input type="' + input.type + '" style="display:inline; width:auto;" name="' + iName + '" value="' + input.value + '" autocomplete="off"/> ' + fLabel))
    } else if ( input.type == 'select' ) {
        iLabel = input.label ? '<label class="' + this.options.name + '-label">' + input.label: '';
        fLabel = input.label ? '</label>': '';
        input.value = input.value === undefined ? '': input.value;
        iName = input.name === undefined ? this.options.name + '-select-' + i: input.name;
        this.esqueleto.inputs.append($(iLabel + '<select name="' + iName + '"></select>' + fLabel));
        $.each(input.options, $.proxy(function(ip, ap) {
            ap.value = ap.value === undefined ? '': ap.value;
            iName = ap.name === undefined ? this.options.name + '-option-' + ip: ap.name;
            $('select[name=' + input.name + ']').append($('<option value="' + ap.value + '">' + ap.label + '</option>'))
        }, this));
    }
    
    inputs  : [
        { type: "select", name: "select", label: "select:", options: [{ label: "option1", value: "option1" },{ label: "option2", value: "option2" }] }
    ]
    

    在 Javascript 代码中找到这一行:

    this.close(this.toArguments($('input', this.esqueleto.inputs)))
    

    并添加 , select 作为 jQuery 选择器来获得这个:

    this.close(this.toArguments($('input, select', this.esqueleto.inputs)))
    

    和 CSS:

    .jquery-msgbox-inputs select
    {
        display: block;
        padding: 3px 2px;
        border: 1px solid #dddddd;
        margin: 3px 0 6px 0;
        width: 97%;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-12
      • 1970-01-01
      • 2022-11-01
      • 2019-04-08
      • 2018-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多