I have a form created and a drop down added which has options populated from database. Now I am trying to add another field that will automatically populate the corresponding value (from database), based on the selected option from the drop down. I have gotten this far but cannot seem to be able to add the 2nd field. Any suggesstions? I am beginner and still learning
wpcf7_add_shortcode('dropdown', 'my_new_createbox', true);
function my_new_createbox(){
global $wpdb;
$table_name = "calendar";
$events_title = $wpdb->get_results("SELECT * FROM $table_name");
$output = "<select name='events' id='events' onchange='document.getElementById(\"events\").value=this.value;'><option></option>";
foreach ( $events_title as $events_title ) {
$title = $events_title->event_title;
$output .= "<option value='$title'> $title </option>";
}
$output .= "</select>";
return $output;
}
The corresponding data for events_title is stores in events_short which I am trying to fetch and populate in another field.