简体   繁体   English

在多选复选框中,我希望在首次打开页面时选择单个值。 我做不到。 我怎么能够?

[英]In the multiple choice checkbox, I want a single value to be selected when the page is first opened. I couldn't. How can I?

In the multiple choice field, I want the value to be selected as soon as the page is opened for the first time.在多选字段中,我希望在第一次打开页面时立即选择该值。 I am inexperienced in this.我对此没有经验。 I could not do it.我做不到。 I would be glad if you help.如果你能帮忙,我会很高兴。

.cshtml code: .cshtml 代码:

<div style="margin:5px 0;"></div>
                <a class="btn btn-default" style="width:100%" ng-show="queryRayonIdBool" ng-click="showRayon()">Choose department...<span class="glyphicon glyphicon-chevron-down pull-right"></span></a>
                <div class="listbutton" ng-show="ShowRayon">
                    <div class="listbox" data-offset-top="50">
                        <a class="btn btn-default allselectbutton" ng-click="checkrayon()">Select All</a>
                        <a class="btn btn-default allselectbutton" ng-click="checkrayonnot()">Remove All</a>
                    </div>
                    <div style="padding-top:20px;">
                        <div style="float:none;" ng-repeat="ray in rayons">
                            <label class="checkbox-inline">
                                <input ng-model="ray.checked2" type="checkbox" value="{{ray.Id}}" ng-click='Checked2(ray)' /><p>{{ray.title}}</p>
                            </label>
                        </div>
                    </div>
                </div>

.js code: .js 代码:

$scope.Checkedval2 = "";
$scope.CheckedId2 = "";
$scope.checkrayon = function () {
    $scope.CheckedId2 = "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22";
    angular.forEach($scope.rayons, function (value, key) {
        value.checked2 = true;

    });
}


rayondata = [];
rayondata.push({ 'id': 0, 'title': "Choose Department... (All Departments)" });
arkadashttp.get(arkadasservice.appOrigin + "/api/RayonApi/GetList",
{})
.then(function (rdata, status) {

    angular.forEach(rdata, function (item) {
        rayondata.push({ 'id': item.Id, 'title': item.RayonName });

    });
});

$scope.ProcessedNames = rayondata;
$rootScope.rayons = rayondata;
$scope.showRayon = function () {
    $scope.ShowRayon = !$scope.ShowRayon;

}

How can I make a change so that the value I want is selected when the page is opened for the first time?如何进行更改,以便在第一次打开页面时选择我想要的值? Thank you very much in advance.非常感谢你提前。

You should be able to add checked to the element.您应该能够将 checked 添加到元素。 This should have it selected by default on page load.这应该在页面加载时默认选择它。

<input ng-model="ray.checked2" type="checkbox" value="{{ray.Id}}" ng-click='Checked2(ray)' checked />

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当单击按钮时,我希望多个选定的复选框行从弹出页面显示到父页面 - when the button is clicked i want the multiple selected checkbox row to be displayed from popup page to parent page 使用jQuery打开链接会打开相关的应用程序,但是,继续进行此操作,会打开一个烦人的about:空白页面。 我该如何阻止呢? - Opening a link with jQuery opens the relevant app but, proceeding this, an annoying about:blank page is opened. How can I stop this? 我希望默认打开第一个 li,当我单击打开的“a”标签时,ul 后面的不关闭 - I want the first li be opened by default and when I click on an "a" tag that is opened the ul following don't close 我想在页面打开时保持第一个切换打开。 如何才能做到这一点? - I want to keep the first toggle opened whenever the page opens. How can this be done? 打开时尝试将数据从数据库传递到引导程序模式。 我该怎么做呢? - Trying to pass data from a database into a bootstrap modal when opened. How do I go about doing this? 选中复选框后,如何刷新页面的一部分? - How do I refresh part of a page when a checkbox is selected? 我如何通过Ajax发送所选复选框的值 - How can i send the value of the selected checkbox through ajax 如何将选定的复选框值输入数据库? - How can i get selected checkbox value into database? 如果选中,如何获取复选框下拉值? - How can I take checkbox dropdown value if it is selected? 我怎样才能获得价值 <select>什么时候在PHP中选中复选框? - How can I get the value of <select> when checkbox is being selected in php?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM