How to Populate dropdown based on another dropdown

Home Forums Quform WordPress How to Populate dropdown based on another dropdown

This topic is: not resolved
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #13678
    i2devapps
    Participant

    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.

    #13695
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy