checkbox

Listview's checked items not there after scrolling

时光总嘲笑我的痴心妄想 提交于 2019-12-19 04:35:12
问题 I have created a listview with textview and checkbox. However after scrolling the list down(or up) all the checked items in the list get unselected. How to make the checked checkboxes retain their state after scrolling? 回答1: ListView recycles the views every time it is scrolled. That's why the Check-boxes does not retain their states. To accomplish your task: Store the checked items in an array. When you click any checkbox in the listview, change the value of that particular item in the array

how to add a checkbox in a listview?

99封情书 提交于 2019-12-19 04:06:18
问题 i have a question, been stuck for a while, i dont know how can i add a checkbox in the list, for example if I have a list of items i want to be able to check them. my xml code is the following: <LinearLayout android:id="@+id/topLayout" android:orientation="vertical" android:layout_width="fill_parent" android:layout_centerHorizontal="true" android:layout_height="wrap_content"> </LinearLayout> <LinearLayout android:id="@+id/middleLayout" android:orientation="horizontal" android:layout_height=

How to get checkbox value from FormCollection?

被刻印的时光 ゝ 提交于 2019-12-19 03:41:42
问题 I have a checkbox and button: @using(Html.BeginForm()) { <div id="search-block"> <input type="checkbox" name="showAll" id="showAll">Include completed <input type="submit" value="Apply"/> </div> } and second thing in controller: [HttpPost] public ActionResult Index(FormCollection collection) { var showAll = collection["showAll"]; TempData["showAll"] = showAll; ... something ... } It's actually working, BUT: If checkboxes are not checked, I am receiving null (doesn't bother me much). If

Check all checkboxes on page load with jQuery

夙愿已清 提交于 2019-12-18 21:19:11
问题 On page load, using jQuery how can I select all check boxes in a specific div automatically? 回答1: $(function(){ $('#thediv input:checkbox').attr('checked', 'checked'); }); 回答2: People seem genuinely confused about how to do this in jQuery. Checking a checkbox is much easier and more efficient without it. The following uses jQuery's strengths of selecting and iterating over a list of nodes combined with the couldn't-be-simpler DOM checked property of checkbox elements: $("#myDiv input:checkbox

Get checkbox status using javascript

廉价感情. 提交于 2019-12-18 21:04:18
问题 This is my checkbox HTML code <input id="termsCheckbox" name="termsCheckbox" type="checkbox" value="terms" <?PHP echo $terms; ?> class="checkbox"> this is javascript code var terms = $("#termsCheckbox"); function validateTerms(){ if(termsCheckbox.checked == false){ terms_div.addClass("terms_error"); return false; } else{ terms_div.removeClass("terms_error"); return true; } } I want to check whether checkbox checked or not and if not add a class to terms_div. Please help me to solve this

jQuery checkbox values to comma separated list

和自甴很熟 提交于 2019-12-18 19:27:12
问题 I have several checkboxes with a name array and I want the output of the checked boxes to be a variable with a comma separated list. <input type="checkbox" name="example[]" value="288" /> <input type="checkbox" name="example[]" value="289" /> <input type="checkbox" name="example[]" value="290" /> For example if the first and last box are selected the output will be: var output = "288,290"; How can I do this with jQuery? 回答1: You can use :checkbox and name attribute selector ( :checkbox[name

How to add event listener for checkbox in Chrome extension's popup?

我的未来我决定 提交于 2019-12-18 18:57:53
问题 I'm trying to capture changes of checkbox in popup of my Chrome Extension. Documentation says: Inline JavaScript will not be executed There is an example provided on the same page, but it for button . I don't know how to modify it so it would capture chekbox's state changes. document.addEventListener('DOMContentLoaded', function () { document.querySelector('button').addEventListener('click', clickHandler); }); 回答1: Had the same problem but reference a very helpful site which list events in

How to add event listener for checkbox in Chrome extension's popup?

隐身守侯 提交于 2019-12-18 18:57:50
问题 I'm trying to capture changes of checkbox in popup of my Chrome Extension. Documentation says: Inline JavaScript will not be executed There is an example provided on the same page, but it for button . I don't know how to modify it so it would capture chekbox's state changes. document.addEventListener('DOMContentLoaded', function () { document.querySelector('button').addEventListener('click', clickHandler); }); 回答1: Had the same problem but reference a very helpful site which list events in

How to add event listener for checkbox in Chrome extension's popup?

时间秒杀一切 提交于 2019-12-18 18:57:10
问题 I'm trying to capture changes of checkbox in popup of my Chrome Extension. Documentation says: Inline JavaScript will not be executed There is an example provided on the same page, but it for button . I don't know how to modify it so it would capture chekbox's state changes. document.addEventListener('DOMContentLoaded', function () { document.querySelector('button').addEventListener('click', clickHandler); }); 回答1: Had the same problem but reference a very helpful site which list events in

What is the purpose of the `name` attribute in a checkbox input element?

谁说我不能喝 提交于 2019-12-18 18:54:13
问题 I went through many online documents for the checkbox input in XHTML. Can anyone clear my doubt? What does this name field actually stand for? Milk: <input type="checkbox" name="checkbox" value="Milk"> Chocolate: <input type="checkbox" name="checkbox" value="chocolate"> Cold Drink: <input type="checkbox" name="checkbox" value="Cold Drink"> I thought it was an identifier for that particular checkbox, which can later be used in other file by just referring their name, but given that all the