How to create Dependent Dropdown List?

My dropdown :

https://paste.ofcode.org/3aduvzMEnLGEnEYVMbhUbT4

If the first dropdown " 3 Compact " is selected second dropdown should not be able to select " 3 Compact" & if first dropdown " 5 Regular" is selected second dropdown should not be able to select below values of 5 Regular like "3 Compact, 3 Regular, 3 Triple, 5 Compact.

The logic is, if first dropdown value selects like 5, second dropdown value must select above 5 not 4 or 3 or 2 or 1.

use in_array and unset

https://www.php.net/manual/en/control-structures.if.php

If 5 Regular is selected in the 1st menu, can 5 Triple be selected in the 2nd menu?

In any case, you need to dynamically produce the menus, by defining the choices in an array, then looping over the defining array to produce the output. This will let you make the option choice ‘sticky’ and with the appropriate data definition, implement the logic you are asking about.

Sponsor our Newsletter | Privacy Policy | Terms of Service