Home › Forums › Quform WordPress › How to Populate dropdown based on another dropdown
HI Support,
I have two dropdown menu one for states and other one for cities, I want to retrieve cities based on states both of them from database
I’m success to retrieve data for one dropdown using your code as below:
function enterreport_dynamic_dropdown_values($form) { $options = array(); $dbc = mysqli_connect(‘dbhost’, ‘dbuser’, ‘dbpasswd’, ‘dbname’); $query = “SELECT * FROM dbtable”; $result = mysqli_query($dbc, $query);
while ($row = mysqli_fetch_assoc($result)) { $options[] = array(‘label’ => $row[‘dbcolum’], ‘value’ => $row[‘dbcolum’]); }
$dropdown = $form->getElement(‘iphorm_1_28’); if ($dropdown instanceof iPhorm_Element_Select) { $dropdown->setOptions($options); } } add_action(‘iphorm_pre_display_12’, ‘enterreport_dynamic_dropdown_values’);
can you help achieve what I want?
Regards.
You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.