【发布时间】:2020-02-08 10:42:56
【问题描述】:
我在j-table 中有一个drop-down,我想从中提取selected value。有没有办法从 j-table 中获取 selected option 值。
sections_template_id: {
title: 'Template',
inputTitle: "Template*",
options: web_sections,
create: true,
edit: true,
list: true
}
, sec_hidden: {
type: 'hidden'
, inputTitle: "Template*"
, create: true
, edit: false
, list: false
, defaultValue: web_sections
}
我想在sec_hidden中设置sections_template_id的值
这是我调用函数的路线
Route::post('cms-web-section-templates',['as' => 'cms-web-section-templates', 'uses' => 'CmsController@Main_sections']);
这是我的功能
public function Main_sections(Request $request)
{
$types = SectionType::getTypes();
$web_section = WebTemplate::all();
//dd($web_section);
$rows[] = array("DisplayText"=>"", "Value"=>"");
foreach ($web_section as $key => $web_sections) {
$rows[] = array(
'DisplayText' => $web_sections->name,
'Value' => $web_sections->id,
);
}
$this->response['Options'] = $rows;
$this->response['Result'] = "OK";
return json_encode($this->response);
}
【问题讨论】:
-
你能提供一个你的代码的工作示例吗?
-
@obscure 如果你能帮助我,我确实编辑了我的问题
-
你能显示表格和下拉选择吗?
-
@user10971804 发布的代码很长..sections_template_id: { title: 'Template', inputTitle: "Template*", options: web_sections, create: true, edit: true, list: true }这是我想要获取的 id 部分的选择
-
只需像
$('#selectID').on('change',function(){ var value = $(this).val();})这样通过 selectID 获取数据。如果选择器是一个类,这仍然有效。
标签: javascript jquery jquery-jtable