Search code examples
javascriptphpjqueryformsnette

Dynamic select values in form


I have form for searching through products that encapsulates three selects: material, weight, and color. These selects contain values from database.

I would like to have a following behavior:

  • If user selects material, the remaining two selects will display only values that are acceptable for products with a given material
  • Apply this to all three selects vice versa

Before I started with nette, I had been doing this using ajax and jquery/javascript by dynamically changing select elements, after user selected value in other select.

I believe in nette should be some good (system) solution, how to reload select's values in a corresponding presenter. Can you help me please?


Solution

  • Just look into the documentation of nette. In my opinion, this is what you are searching for: http://pla.nette.org/en/dependent-form-select-with-ajax

    You can write handles for select changes, and in those handles load to form remaining selects. No messy work with javascript.