php - 如何确保在一个下拉列表中选择的值将更改 Laravel 中另一个下拉列表的值
问题描述
我正在开发 Laravel 项目,我想要实现的是,当用户在下拉列表中选择某个值时,它应该会影响视图中的其他下拉列表,也就是说,如果用户在第一个下拉列表中选择收入,则应该禁用费用下拉列表或类似那个控制器的东西
> public function create()
> {
> $income = Income::pluck('title', 'id');
> $expense=Expenses::pluck('title', 'id');
> return view ('IncomeExpense.create', compact('income','expense'));
> }
看法
<div class="form-group">
> {{Form::label('IncomeExpense', 'Income&Expense')}}
> {{Form::select('IncomeExpense', array('E' => 'Expense', 'I' => 'Income'),null,['class'=>'form-control'])}}
> </div>
> <div class="form-group">
> {{Form::label('', 'Income')}}
> {{Form::select('IncomeId', $income,null,['class'=>'form-control'])}}
> </div>
> <div class="form-group">
> {{Form::label('', 'Expense')}}
> {{Form::select('ExpenseId', $expense,null,['class'=>'form-control'])}}
> </div>
解决方案
在放置类的数组中,您还可以像这样分配一个id
{{Form::select('IncomeId', $income, null,['class'=>'form-control', 'id' => 'MyAwesomeId'])}}
然后,您可以像使用普通 html 一样使用 javascript/jquery。
推荐阅读
- dart - 为什么使用列表
当堆栈返回 _GrowableList - meteor - 流星不在网页中添加和显示任务,它只是闪烁和故障(创建待办事项列表以添加和删除任务)
- android - 如何解决“javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:找不到证书路径的信任锚。”
- git - 如何将两个旧提交合并为一个?
- visual-studio - MSB4067:元素下方的元素 <#text>
无法识别 - python - Python Popen 无法识别命令行开关
- php - WordPress wp-admin 仪表板
- c# - 将值动态添加到 MS 访问数据库并使用变量检索它们
- sql - 在表中的 sql 中,在具有数据类型文本的给定列中,我们如何在特定条目之后显示该列中的其余条目
- java - 如何在 Spring Boot 1.5.9 中模拟自定义 Jackson 反序列化器响应