简体   繁体   English

如何让Struts2选择标签readonly

[英]how to make Struts2 select tag readonly

I want my <s:select> to be readonly, I don't want it to be disabled because I have to submit the value of <s:select> to my action class. 我希望我的<s:select>是readonly,我不希望它被禁用,因为我必须将<s:select>的值提交给我的action类。

Here is other question related to this ( Question ), but the answer given has not worked here. 这是与此相关的其他问题( 问题 ),但给出的答案在这里没有用。

Is there any way to readonly my <s:select> , how can I achieve this??? 有没有办法只读我的<s:select> ,我怎么能实现这个???

You can make the <s:select> tag disabled and have a hidden field having its name and value . 您可以disabled <s:select>标记,并使隐藏字段具有其名称和值 so, that it can be sent in the request to the server for processing. 所以,它可以在请求中发送到服务器进行处理。

Thank Keerthivasan 感谢Keerthivasan

Example

<s:select value="aaa" id="source_id" listValue="name" disabled="true" />
<s:hidden name="destination_name" />


$('input[name="destination_name"]').val(
    $("#source_id option:selected").val()
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM