开发者

Submit all options from multi select list box with jquery.form.js plugin

in my code, inside form, I have multi select list box:

<SELECT style="width: 250px;" id="data" multiple="multiple" name="data">
   <OPTION value="111" selected="selected">111</OPTION>
   <OPTION value="222">222</OPTION>
   <OPTION value="333">333</OPTION>
</SELECT>

Submit all options from multi select list box with jquery.form.js plugin

For submitting the form I'm using jquery.form.js plugin.

$(document).ready(function () {
        var options = {
            beforeSubmit: showRequest, 
            success: showResponse  
        };

        $('#myForm').ajaxForm(options);
    });

The plugin submits only the values wit开发者_运维问答ch are selected: 111. How to force it to serialize and submit all values, not only selected ones: 111, 222 and 333 ?

Btw: The event showRequest looks following:

showRequest: function (formData, jqForm, options) {
            //.. 
            return true;
        },

I thaught I can modify formData inside this function, and pass this overloaded object for submitting. But there is no such option, is there ? Nothing changes also, when I iterate here through all select options and force all to have selected attribute.

Any ideas ? I'd like to use this plugin, I don't want to submit form by my custom code.

Regards

Update: @JK, @Luke, just for short explanation, I'd like to submit all options, despite selection, for example when I have following situation:

Submit all options from multi select list box with jquery.form.js plugin

So I don't have list of strictly defined options, where I can just select or deselect some of them. In my case, I can create new options and I need the functionality I described.


Well, it seems you already have the data (in formData), so try to add a field there with all the values —how you serialize it is entirely your decision.

If this doesn't work, try adding hidden fields to store the values. You can either create one and enconde the values, or create many (with the same name), one for each value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜