drqja5919276 2013-09-03 14:06
浏览 32

根据下拉列表预填充第二个字段

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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
    • ¥30 eclipse开启服务后,网页无法打开
    • ¥30 雷达辐射源信号参考模型
    • ¥15 html+css+js如何实现这样子的效果?
    • ¥15 STM32单片机自主设计
    • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
    • ¥15 不小心不正规的开发公司导致不给我们y码,
    • ¥15 我的代码无法在vc++中运行呀,错误很多
    • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
    • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000