问题描述:

I am having a dropdown box and a 5 textfields( all disabled). I am entering data into textfield by using javascript, from the dropdown(what ever value is present in the dropdown, goes into the text fields).

Now, when the submit button is clicked, I want to get the value from this text field in the action class(java). On testing, I was getting "null" [getParameterValues("textfieldname") is what I have done].

When I removed the disabled, I was getting the value. So, how can I get the value while the disabled, is applied to the text field ?

网友答案:

Instead of disable them make them readonly.

<input type="text" name="nameOfTextField" readonly="readonly" />
网友答案:

if you want the field to be disabled you can use an hidden input like this:

<input type="text" id="nameVisible" disabled="disabled" />
<input type="hidden" name="nameObj" id="nameObj"/>

when you load page, you set value in both fields via DOM
in this way you'll see the input disabled on the page, and you'll get the hidden value when you submit it.

相关阅读:
Top