user546352
user546352

Reputation: 121

List of hidden fields on a servlet

There is a dynamic form which gets build based upon an excel spread sheet. The form itself can have an embedded javascript which can hide and show elements. Now, I have a servlet which needs to get the list of all hidden items. I was hoping to get this list based upon the fact that these values would be null in request parameter, apparently they are all send, hidden and shown elements as empty strings.

Is there anyway to get the style-class of all items on html page? Or some other trick to help this situation?

Upvotes: 1

Views: 278

Answers (2)

biziclop
biziclop

Reputation: 49754

The only way is to have a dedicated hidden field that contains the list of all the currently visible fields, and make your JS keep it up to date.

Having said that, if your application logic depends on this kind of trickery, it might be a good idea to rethink the design. (Obviously I don't know all the circumstances, so you may have a very good reason to do this, but from the little you revealed, it looks a bit suspicious.)

Upvotes: 0

BalusC
BalusC

Reputation: 1108852

If you hide an input field using JavaScript and you don't want to send its value as parameter to the server, then use JavaScript to disable the input field as well.

E.g.

input.style.display = 'none';
input.disabled = true;

The client won't send the values of disabled inputs to the server. You'll get null then when attempting to get the request parameter by input's name.

Upvotes: 1

Related Questions