Dynamic form: selection and form: option in Spring form tags

Consider the following scenario:

I use Spring form tags to help process the form. I use a with tags. Values โ€‹โ€‹are entered in select using ENUM. However, now you need to make the parameters dynamic and reliable for another control in the form. Depending on the choice of value in another control show and hide certain options or add additional parameters. I looked pretty complicated and researched, but Spring tags do not support this use case of sorta. How do I solve this problem.

I have a solution, but I donโ€™t know how much better it is. Set the cssClass attribute for the parameters and show and hide the parameters using jquery / javascript.

Please suggest a suitable solution if you encounter this problem.

+4
source share
1 answer

This requires jQuery. One option is to create a text file for every opportunity. Each file will contain new parameters along with the html replacement text (see below). Then use jQuery to see the change of the first selection.

Text File <option>Bar</option> <option>Bar</option> Script $("#first-choice").change(function() { $("#second-choice").load("textdata/" + $(this).val() + ".txt"); }) 

You can find other options described in detail here.

0
source

Source: https://habr.com/ru/post/1499326/


All Articles