Hide certain value in dropdown B when user choose certain value in dropdown A

chekwan 23 Sep, 2018
I have 2 dropdown with same value.

I want value in dropdown B will hide when user choose the value in dropdown A.

Example:
user choose value 1, and same value in dropdown B will hide.

Dropdown A
value 1
value 2
value 3

Dropdown B
value 1
value 2
value 3


How can achieve this since I'm zero knowledge in programming.
healyhatman 23 Sep, 2018
Easiest way is to reload the second dropdown and use some code to determine which values you will display. Have a look at the "Dynamic dropdown" demo form.
chekwan 23 Sep, 2018
Hi Healyhatman,

Both dropdown must be show on load.
But I only want to hide the certain value inside the the dropdown.

I have tested the Dynamic dropdown on demo form,

but the value in second dropdown not appear when the value is "?"
$options = [];
switch($this->data('what_do_you_think')){
case '?':
$options = ['2' => '2', '3' => '3', '4' => '4'];
break;
case 'good':
$options = ['2' => '2', '3' => '3', '4' => '4'];
break;
case 'bad':
$options = ['1' => '1', '3' => '3', '4' => '4'];
break;
case 'so':
$options = ['1' => '1', '2' => '2','4' => '4'];
break;
case 'test':
$options = ['1' => '1', '2' => '2','3' => '3', '4' => '4'];
break;
}
return $options;
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger