Anand
Anand

Reputation: 707

Making elements non-editable in Struts using jQuery

I am using Struts and jQuery for one of my web applications. In one of the screens, some elements need to be disabled based on certain conditions. For ex, If a val of variable test is "Employee", then a drop down box (select box in struts) should be disabled. User should not be allowed to select a value. System will assign a value based on the value in variable test.

I tried to use the following options.

  1. $("#selectBox").prop('disabled','disabled');

  2. $("#selectBox").prop('disabled',true);

  3. $("#selectBox").prop('readonly','readonly');

  4. $("#selectBox").prop('readonly',true);

I used the method attr to set the values. The disabled attribute makes the dropdown non-editable, but the values are not set into the struts bean and so the values are not available in the Action class. The last 2 options did not make the drop down non-editable.

How to make the struts elements like select box, check box non-editable in jQuery on conditional basis?

Upvotes: 0

Views: 401

Answers (1)

Philip
Philip

Reputation: 81

You can set the disabled attr with true, and use a input hidden field to submit the value.

Upvotes: 1

Related Questions