在html中从下拉列表中选择项目时禁用字段
disable fields when selecting a item from dropdown in html
我正在尝试创建一个表单,到目前为止,我已经完成了所需的一切。但问题是,当我从选择下拉列表中选择一个项目时,我想禁用几个字段。
例如,如果我从交易类型中选择"公司内部"选项,那么下面的所有其他字段都应该被禁用(不应该能够输入数据)。我怎样才能做到这一点?
在这里我会张贴我的代码
<ion-content class="has-header" scroll="true" padding="true">
<form id="myForm">
<label><h4><b>Source Account Number</b></h4></label>
<select id="originAcc" style="margin: auto; width:100%; " ng-model="data.origin" ng-options="account.account for account in accountsArr">
<option value="" selected="selected">--Select Account--</option>
</select><br><br>
<label><h4><b>Transfer Amount</b></h4></label>
<input type="number" id="amount" name="amount" ng-model="data.amount" class="item-input-wrapper" decimal-places onkeypress='return event.charCode >= 48 && event.charCode <= 57 || event.charCode == 46'>
<br>
<label><h4><b>Beneficiary Account Number</b></h4></label>
<input type="text" id="beneAcc" name="beneAcc" ng-model="data.beneAcc" class="item-input-wrapper" >
<br>
<label><h4><b>Beneficiary Name</b></h4></label>
<input type="text" id="beneName" name="beneName" ng-model="data.beneName" class="item-input-wrapper" >
<br>
<label><h4><b>Transaction Type</b></h4></label>
<select id="transtype" style="margin: auto; width:100%; " ng-model="transtype" ng-options="type.type for type in types">
<option value="" selected="selected">--Select Transaction Type--</option>
</select>
<br><br>
<label><h4><b>Select Bank</b></h4></label>
<select id="beneBank" style="margin: auto; width:100%; " ng-model="data.beneBank" ng-options="bank.bank for bank in banks">
<option value="" selected="selected">--Select Bank--</option>
</select>
<br><br>
<label><h4><b>Branch Name</b></h4></label>
<select id="beneBank" style="margin:auto; width:100%;" ng-model="data.beneBank" ng-options="bname.bname for bname in bname">
<option value="" selected="selected">--Select Branch Name--</option>
</select>
<br><br>
<label><h4><b>Fund Transfer Remarks</b></h4></label>
<input type="text" id="narration" name="narration" ng-model="data.narration" class="item-input-wrapper">
<input type="checkbox" name="option1" value="beneficiary"> Save as beneficiary<br><br>
<div class="col" style="text-align: center">
<button align="left" class="button button-block button-reset" style="display: inline-block;width:100px;text-align:center " ng-click="reset()" padding-top="true">Reset</button>
<button class="button button-block button-positive" style="display: inline-block;width:100px;margin-left:auto; margin-right:auto; " ng-click="thirdPartySubmit(data)" padding-top="true" >Transfer</button>
</div>
</form>
</ion-content>
</ion-view>
禁用使用ng//////
<select id="transtype" style="margin: auto; width:100%; " ng-model="transtype" ng-options="type.type for type in types" data-ng-change="hideFields()">
<option value="" selected="selected">--Select Transaction Type--</option>
控制器内
$scope.hideFields = function() {
if($scope.transtype == "within company") {
$scope.disableFileds = true;
}
}
可视
<input type="text" id="beneAcc" name="beneAcc" ng-model="data.beneAcc" class="item-input-wrapper" ng-disabled="disableFileds">
//这样做可以禁用字段
/////////https://docs.angularjs.org/api/ng/directive/ngDisabled
相关文章:
- 将输入字段中的文本提交到我的数据库,同时将其添加到我的列表中
- 而循环只设置php中输入字段中的第一个值
- 在输入字段中将最小金额设置为
- 范围$手表项目doens'不适用于javascript对象的字段
- 提交带有已使用jQuery移动的列表框项目的隐藏字段
- 如何在选择项目时使用 ajax 将数据提取到输入字段中
- Jquery- 动态添加字段 - 防止删除最后一个项目
- 使用 lodash 按多个字段对数组中的项目进行排序
- 如何移除 DOJO 数据存储添加到我提取的项目中的所有额外字段
- 使用javascript修改select字段中的项目顺序
- 显示按字段分组的项目
- Jquery UI自动完成不同的渲染项目结果相同的字段
- 这个项目缺少什么?即使字段为空,表单也会被接受
- 如何使用jsGrid在字段中获得项目的下拉列表
- 如何使用带有输入字段的表单将项目推送到控制器数组中,该表单将显示在视图中
- 如何将所选项目存储在“;选择“;字段
- 动态创建的getmdl选择字段's的下拉窗口没有'单击项目时不要关闭
- 套件脚本 从多选字段加载项目记录
- 需要帮助,以显示不同的字段与帮助项目符号在HTML表单
- JQuery引导模式窗口以某种方式重载/清除Ruby on Rails项目中的父字段