如何将禁用的多重选择值发送到服务器

时间:2018-10-25 09:34:13

标签: javascript java arrays select struts

我有以下选择,即多选

<html:select property="select1" styleId="select1" style="width:330px;" size="6" multiple="true" disabled="true">
    <html:optionsCollection property="wo" value="id" label="idAndRef"    />                                         
</html:select>

<html:hidden property="select1"  styleId="select1"/>

由于选择被禁用,我具有隐藏属性。

由于选择为disabled

,因此我可以设置以下值
var select = document.getElementById('select1');
if (select.disabled) {
    // If disabled, do this 
    var allOptions = new Array;
    $('#styleId option').each(function(){
        allOptions.push($(this).val());
    });

    var arrayLength = allOptions.length;
    for (var i = 0; i < arrayLength; i++) {
        select.options[i].value = allOptions[i]
        select.options[i].selected = true;
    }

    //document.forms[0].styleId.value=allOptions; 
    return true;
}

但是当我调试并检入服务器时,我得到以下内容作为select1

的值
[[Ljava.lang.String;@42205593]

我不明白为什么上面一个是值而不是字符串数组。

private String[] select1 = new String[] {}; //is how it is declared in struts form.

0 个答案:

没有答案