EzDevInfo.com

checked

<img class="emoji" title=":white_check_mark:" alt=":white_check_mark:" src="https://assets-cdn.github.com/images/icons/emoji/unicode/2705.png" height="20" width="20" align="absmiddle"> UI components using :checked CSS pseudo-class selectors. checked: UI components using :checked CSS pseudo-class selectors.

C# checked block

Can someone explain to me what exactly is the checked an unchecked block ?
And when should I use each ?


Source: (StackOverflow)

Check first radio button with JQuery

I would like to check the first radio button of each group. But there are some radio button that are disabled, so the script should ignore them and go to next non-disabled button.

I wrote something like this but it doesn't work:

$(document).ready(function(){
if ($("input['radio']).is(':disabled'))
    {  
        $(this).attr('checked', false );
    }
else
    {
        $(this).attr('checked', true );
    }
});

Thanks a lot


Source: (StackOverflow)

Advertisements

How do you get the checked value of asp:RadioButton with jQuery?

I need to do something like this:

<asp:RadioButton ID="rbDate" runat="server" Text="Date" GroupName="grpPrimary" />

and be able to check the value of the radio button's checked value in jQuery, but my attempts like these don't return true/false.

if ($('[name=rbDate]').attr("Checked"))

if ($('[name=rbDate]').attr("Checked").val())

if ($('[name=rbDate]:checked').val())

A little help?


Source: (StackOverflow)

Find out if radio button is checked with JQuery?

I can set a radio button to checked fine, but what I want to do is setup a sort of 'listener' that activates when a certain radio button is checked.

Take, for example the following code:

$("#element").click(function()
{ 
    $('#radio_button').attr("checked", "checked");
});

it adds a checked attribute and all is well, but how would I go about adding an alert. For example, that pops up when the radio button is checked without the help of the click function?


Source: (StackOverflow)

if checkbox is checked, do this

When i check the checkbox, i want it to turn P #099ff, when i uncheck the checkbox i want it to undo that. Should I do this a different way?

$('#checkbox').click(function(){
    if ($('#checkbox').attr('checked')) {
        SOME FUNCTION
    }
}) 

sorry i should have been more clear, when the checkbox is checked, i want it to enable a function, when it's unchecked, to disable that same function.


Source: (StackOverflow)

What is the difference between the states selected, checked and activated in Android?

I'd like to know what differs those states. I didn't find any webpage clarifying this.


Source: (StackOverflow)

Why dividing int.MinValue by -1 threw OverflowException in unchecked context?

int y = -2147483648;
int z = unchecked(y / -1);

The second line causes an OverflowException. Shouldn't unchecked prevent this?

For example:

int y = -2147483648;
int z = unchecked(y * 2);

doesn't cause an exception.


Source: (StackOverflow)

How Can I get the text of the selected radio in the radio groups

as said in the title for example:

<input id="User_Type_0" type="radio" name="User_Type" value="1" checked="checked" />
<label for="User_Type_0">User1</label>
<input id="User_Type_1" type="radio" name="User_Type" value="2" />
<label for="User_Type_1">User2</label>

how can I get the text:User 1


Source: (StackOverflow)

Java unchecked/checked exception clarification

I've been reading about unchecked versus checked questions, none of the online resources have been truly clear about the difference and when to use both.

From what I understand, both of them get thrown at runtime, both of them represent program states that are outside the expected bounds of the logic, but checked exceptions must be explicitly caught while unchecked ones do not.

My question is, suppose for argument's sake I have a method that divides two numbers

double divide(double numerator, double denominator)
{    return numerator / denominator;    }

and a method that requires divison somewhere

void foo()
{    double a = divide(b, c);    }

Who is responsible for checking the case of the denominator being zero, and should an exception be checked or unchecked (ignoring Java's built in divison checks)?

So, would the divide method be declared as is or as

double divide(double numerator, double denominator) throws DivideByZeroException
{
    if(denominator == 0) throw DivideByZeroException
    else ...
}

void foo()
{
    try{
        double a = divide(b, c);
    }
    catch(DivideByZeroException e)
    {}
}

or without a checked exception, as is:

double divide(double numerator, double denominator)
{
    if(denominator == 0) throw DivideByZeroException
    else ...
}

void foo()
{
    if(c != 0)
       double a = divide(b, c);
}

and allow foo to make the divide by zero check?

This problem originally arose in a mathematical program I wrote in which users entered numbers and logic classes performed calculations. I was never sure whether the GUI should check immediately for improper values, or whether the internal logic should catch them during calculation and throw exceptions.


Source: (StackOverflow)

jquery radio button when checked need an alert

In my application i need a radio group, in which whenever a button is checked, an alert occur so that i can post its value to ajax post in jquery.

Can you help me please how i can do it in jquery?


Source: (StackOverflow)

How can I get a css pseudo element :checked to work in IE8 without Javascript?

I have two radio buttons, I need to set the background color on click. My code works in all browsers except for IE8. Is this possible to get this to work for IE8 without the use of Javascript?

<form>
    <input type="radio" id="m" name="gender" value="male">
    <label for="m">male</label>
    <input type="radio" id="f" name="gender" value="female">
    <label for="f">female</label>
</form>

input:checked + label{
    background:red;
}

http://jsfiddle.net/chrimbus/sXjyL/3/


Source: (StackOverflow)

How to render an array as a list of radio buttons?

I would like to loop through an array that I define in my Javascript and render a list of radio buttons. My code which isn't working currently, and it is as follows (also on jsfiddle):

<div data-bind="foreach: options" >
    <div>
        <input type="radio" name="optionsGroup" data-bind="checked: selected" />
        <span data-bind="text: label"></span>
     </div>    
</div>
var optionsList = [
    {"value": "a","label": "apple"},
    {"value": "b","label": "banana"},
    {"value": "c","label": "carrot"}
];
function viewModel() {
    var self = this;
    self.options = optionsList;
    self.selected = ko.observable("a");
    self.selected.subscribe(function(newValue) {
        alert("new value is " + newValue);
    });
}
ko.applyBindings(new viewModel());

If my array is part of the html then it works fine, see this (or jsfiddle):

<div>
    <input type="radio" name="optionsGroup" value="a" data-bind="checked: selected"     />Apple
</div>
<div>
    <input type="radio" name="optionsGroup" value="b" data-bind="checked: selected" />Banana
</div>
<div>
     <input type="radio" name="optionsGroup" value="c" data-bind="checked: selected" />Carrot
</div>
<div data-bind="text: selected">
</div>
function viewModel() {
    var self = this;
    self.selected = ko.observable("a");
    self.selected.subscribe(function(newValue) {
        alert("new value is " + newValue);
    });
}    
ko.applyBindings(new viewModel());

I got this to work by generating the all of the html within my javascript and have this working using checkboxes, but am stumped generating a group of radiobuttons using the foreach iterator.

Has anyone gotten an example like my first one to work?


Source: (StackOverflow)

jquery attr('checked','checked') works only once

I have a problem finding reason for the following jquery/checkbox behaviour.

$( this.obj + ' table.sgrid-content > thead > tr > th > input.select_all' ).on( 'click' , {grid:this} , function(event){

var grid = event.data.grid;

if( $(this).is(':checked') ){

    $( grid.obj + ' table.sgrid-content > tbody > tr > td > input.select ' ).attr('checked','checked');
    $( grid.obj + ' .sgrid-content > tbody > tr > td > input.select ' ).parents('tr').addClass('ui-state-highlight');

} else {

    $( grid.obj + ' table.sgrid-content > tbody > tr > td > input.select ' ).removeAttr('checked');
    $( grid.obj + ' table.sgrid-content > tbody > tr > td > input.select ' ).parents('tr').removeClass('ui-state-highlight');

}

});

The code is intended to work as follows: - click on input.select_all triggers the event - if input.select_all is checked: add attribute checked to all checkboxes marked as .select within table.sgrid-content - if not: remove the 'checked' attribute from all input.select items.

Yet another simple grid function. And it works. The weird part is, it works only once. By that I mean, you can select all the checkboxes and deselect them. After that operation "Select all" function stops working.

Another weird thing is, when i check dom elements with firebug they all become checked='checked' attr as they should, but they display and behave as they were not checked.

Selectors work as they should. The code part with adding/removing ui-state-highlight works all the time.

Word of explenation: grid - is the object that I pass to get grid.obj ( basically ID of a ceratain div )

Please give me your opinion.


Source: (StackOverflow)

When must we use checked operator in C#?

When must we use checked operator in C#? Is it only suitable for exception handling?


Source: (StackOverflow)

Android ListView CHOICE_MODE_MULTIPLE, how to set checked index?

I'm using the cool feature of the ListView to show a checkbox next to the item in the ListView. I bind my list to an array of strings. The onClick and onSelectedItem listeners get called fine, in this way I know the index of the "string" checked (or unchecked).

I'm storing all the checked strings into preferences (as a comma-concatenated-string), and everytime the activity becomes visible I would like to set the checked items back in the listview.

Is there a way of doing it? or the CHOICE_MODE_MULTIPLE doesn't allow to set the checked items?

note: I'm not using a custom view, since what I want to display is just a string and a checkbox. I've tried setSelection(index) but it should set the onlyone selected (highlighted) row.

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_multiple_choice,names);
m_playlists_list.setAdapter(adapter);
m_playlists_list.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);

Source: (StackOverflow)