无法访问已禁用的下拉菜单项的值,在动作类(struts 2)中 [英] Cannot access the value of the selected item of a disabled drop down, in action class (struts 2)

查看:143
本文介绍了无法访问已禁用的下拉菜单项的值,在动作类(struts 2)中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Jsp页面上,我有一些选择元素,在选择一个值后被禁用(在javascript中禁用它们)。现在当提交表单时,我无法访问动作类中的这些选定的值。

On a Jsp page I have some select elements which were disabled after a value was selected (Disabled them in javascript). Now when the form is submitted, I can not access those selected values in the action class.

我知道这是由于select元素被禁用引起的,当我尝试相同但不让他们被禁用时,它工作正常。

I know for sure that this is caused by the select elements being disabled because, when I tried the same without making them disabled, it worked fine.

现在我不明白为什么会这样。我想也许我应该在提交表单之前启用它们,但似乎不是一个好主意。

Now I don't understand why is this so. I thought maybe I should enable them before the form is submitted, but it does not seem a good idea.

在实现这个过程中我遇到了这个问题:使用java脚本在jsp上动态创建struts 2表单
(你可以在那里找到代码,虽然我不认为你需要代码,因为它是明确的问题。)

I faced this problem while implementing this : Creating struts 2 forms dynamically on jsp using java script . (You can find the code there. Although I don't think you will need the code, because it is clear where the problem is.)

这里我可以访问文本字段的值,但是我无法访问select元素的值。

Here I am able to access the values of text fields but I can not access the values of select elements.

我单独问了这个问题,因为我认为这是一个不同的主题。

I asked this question separately because I thought this is a different topic.

谢谢!!

推荐答案

您可以将它们设置为隐藏字段通过java脚本将其传递给action

You can set them in hidden field through java script and pass it to action

这篇关于无法访问已禁用的下拉菜单项的值,在动作类(struts 2)中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆