Friday, July 24, 2009

Read-only or protected select box

We were trying to make a select box protected on one of you html pages. As part of capturing information we allow user to select an option, but on amend if the select box is already selected we want to make it read-only or protected.

First thing we did to achieve this is by disabling the select box. This gave us the required functionality on UI, but the select box's value is not reaching the server-side as part of form submit.

Next thing we tried is replacing the select box with a read-only input field of type text. This also gave the required UI feel, but still the value is not reaching the server-side as part of form submit. We then realised that while creating the text field, we gave it an id and other attributes except 'name' attribute. So one need to remember two things to make a value from client to server via form-submit:

1. The field should not be disabled
2. The field must be given the name attribute