checked

Radio button checked event handling

十年热恋 提交于 2019-12-03 05:35:50
问题 In my application, I need a radio group, in which whenever a radio-button is checked, an alert occur so that I can post it's value to ajax post with jQuery. Can you help me please how i can do it in jQuery? 回答1: Try something like this: $(function(){ $('input[type="radio"]').click(function(){ if ($(this).is(':checked')) { alert($(this).val()); } }); }); If you give your radio buttons a class then you can replace the code $('input[type="radio"]') with $('.someclass') . 回答2: Update in 2017: Hey

Radio button checked event handling

馋奶兔 提交于 2019-12-02 20:08:37
In my application, I need a radio group, in which whenever a radio-button is checked, an alert occur so that I can post it's value to ajax post with jQuery. Can you help me please how i can do it in jQuery? Try something like this: $(function(){ $('input[type="radio"]').click(function(){ if ($(this).is(':checked')) { alert($(this).val()); } }); }); If you give your radio buttons a class then you can replace the code $('input[type="radio"]') with $('.someclass') . Update in 2017: Hey. This is a terrible answer. Don't use it. Back in the old days this type of jQuery use was common. And it

keep user checked radiobtn checked even after postback

自古美人都是妖i 提交于 2019-12-02 17:16:26
问题 I have the following radiocontrols with Default checked to "All". If user checks some other radio button and submits, on postback i want to retain the checked button, so users can see what they clicked..How do I keep whatever was selected using jquery?? i am using is: <script type="text/javascript" language="javascript"> $(document).ready(function() { var url = 'http://mysite.com/events/Pages/default1.aspx?kwd='; $(".SearchBoxAndChoices a.searchButton").click(function() { var radioVal = $(

Add class to target based on radio input value (toggle, like function)

我只是一个虾纸丫 提交于 2019-12-02 16:53:27
问题 Summed up answer If you come across something similar here is the simple answer: In my code I get the .val() value of the :checked radio input, that gets the value of all the radios that have been checked, this results in unwanted classes. Taking advantage of the .click callback we can get the .val() value of just the specific input value of the clicked item, which is a radio label in my case. Here is another great solution to the problem I had.. Add class and remove class based on checked

Changing CSS visibility with JavaScript if a checkbox has been checked

≡放荡痞女 提交于 2019-12-02 11:03:40
In the snippet below, blue div should hide when the checkbox is checked. Yet, it doesn't. I've tried a lot of different syntax, but no luck so far. if (document.getElementById("check".checked = "true")) { document.getElementById("box").style.visibility = "hidden"; } #box { background: lightblue; width: 200px; height: 200px; } <input type="checkbox" id="check"> <div id="box"></div> Here is what you wanted. http://jsfiddle.net/3ywqy72w/8/ There were many problems with the code you have placed above. In the HTML, you need to call a function for javascript to do something once the checkbox is

Checkbox within a ListView

扶醉桌前 提交于 2019-12-02 10:06:54
I wish to populate a listview which contains checkbox as list items in an android application. I have implemented a listview, but if I check anyone of the checkboxes in the list it checks some other lists in the listview.. Thanks in advance.. For custom Layout: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <CheckBox android:id="@+id/chk_check" android:layout_width="wrap_content" android:layout_height="48dp" android:layout

keep user checked radiobtn checked even after postback

空扰寡人 提交于 2019-12-02 08:03:09
I have the following radiocontrols with Default checked to "All". If user checks some other radio button and submits, on postback i want to retain the checked button, so users can see what they clicked..How do I keep whatever was selected using jquery?? i am using is: <script type="text/javascript" language="javascript"> $(document).ready(function() { var url = 'http://mysite.com/events/Pages/default1.aspx?kwd='; $(".SearchBoxAndChoices a.searchButton").click(function() { var radioVal = $("input[name='EventType']:checked").val(); var keywords = encodeURIComponent($(".BasicSearchInputBox").val(

Jquery checkbox inside div checked one at time

帅比萌擦擦* 提交于 2019-12-01 22:12:46
问题 So i have a div thats auto generated and inside are 3 check boxes with different id's & names and by default none of them are checked!! If one happens to get checked then i need the other two unchecked!! So only one can be checked at a time ... So all unchecked or only one checked! <div class="configoptions"> <table class="configtable" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td class="fieldlabel">Include:</td> <td class="fieldarea"> <label><input name="configoption[10]" id

How to get the checked items listed in a Qt QListWidget

99封情书 提交于 2019-12-01 21:54:39
I've populated a QListWidget with a list of items and added a check box leaving everything unchecked. for td in root.iter('testdata'): test_data = td.get('ins') item = QtGui.QListWidgetItem(test_data, self.listWidgetLabels) item.setFlags(item.flags() | QtCore.Qt.ItemIsUserCheckable) item.setCheckState(QtCore.Qt.Unchecked) The user then clicks a few of the items in the QListItem and clicks a 'Generate File' button on the gui. self.pushButtonGenerateFile.clicked.connect(self.generate_file) I want to get a list of all the checked QListItems. def generate_driver(self): test = self.listWidgetLabels

Which way to test if an element is checked is better? .is(':checked') or .prop('checked')

我是研究僧i 提交于 2019-12-01 16:22:26
Both .is(':checked') and .prop('checked') can be used to test if a checkbox is checked. Are there any interesting/important differences between those two ways of querying the checked state or is it pretty much only a matter of personal preference? They both end up checking the same thing. If you're using 1.6.0 or higher, prop('checked') is the most direct jQuery way. jQuery doesn't have to parse and process a selector to figure out what to do. [Note below] You can also (as of 1.6.1) use attr('checked') again as with 1.5.x and earlier. Or you can go directly to the element. Assuming x is the