Menu
  • HOME
  • TAGS

check if radio button is checked

javascript,jquery,checked

You're not checking properly whether it is checked or not, so it won't work. Instead, use is() and :checked to check whether it is checked: if($('.survey_kind_input').is(':checked')){ alert('in survey kind checked'); } <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input checked="checked" class="survey_kind_input" type="radio" value="Short"> <input class="survey_kind_input" type="radio" value="Thorough"> ...

Clear input fields when checkbox is checked

angularjs,checkbox,input,clear,checked

The simple approach is to use ngChange directive on checkbox and set text input model to empty string if checkbox is checked. Something like this: <input type="text" ng-model="data.test" ng-disabled="data.check"> <input type="checkbox" ng-model="data.check" value="one" ng-change="data.test = data.check ? '' : data.test"> Demo: http://plnkr.co/edit/pKGui2LkP487jP0wOfHf?p=preview...

Java checked exceptions

java,exception,checked,throws

If the above is correct, does this mean that I need to understand every single checked exception that is built in to Java [...]? Yes, your statements are correct, but no one expects you to know of all potential checked exceptions when programming. And you don't have to if...

Toggle classes on divs when different radios are checked

jquery,radio,addclass,checked,toggleclass

Try jQuery(function($) { $('.option').change(function() { var $this = $(this), $td = $this.parent(), $tr=$td.parent(); $tr.next().add($tr).find('.highlightMe').removeClass('highlightMe'); if(this.checked) { $tr.next().find('td').eq($td.index()).add($td).addClass('highlightMe') } }); }); Demo: Fiddle...

Trigger CSS animation with checkbox inside a fieldset

html,css,animation,checkbox,checked

you could use jquery to give #stuffToAnimate a class $('#playCheck:checkbox').click(function() { if ($(this).is(":checked")) { $("#stuffToAnimate").addClass("animate"); } else { $("#stuffToAnimate").removeClass("animate"); } }); your css will look like this .animate{ -webkit-animation-play-state: running; } ...

.attr('checked') will not tell me that the radio button is checked even when it is

jquery,radio-button,attr,checked

you can use instead: if($('#question1answerA').prop('checked')) ...

Updating togglebutton cheched state gives error

android,xamarin,togglebutton,checked

Try doing like this: playmusicToggleButton = (ToggleButton) findViewById(R.id.playmusicToggleButton); playmusicToggleButton.setChecked(true); ...

jQuery mouseup event not detecting checked attribute?

javascript,jquery,checkbox,mouseevent,checked

The issue is that mouse up runs before the control is actually changed. ex. box is not checked then clicked mouse down - this.checked is false mouse up - this.checked is still false because the control has not actually changed. this.checked is not updated until after mouse up is ran....

jQuery (Mobile): get all checked items (checkboxes)

javascript,jquery,checkbox,checked,prop

$(function(){ $('#names input[type=checkbox]').change(function(){ $("#checked").text($('#names input[type=checkbox]:checked').length); }); }) <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script> <div id="names"> <label> <input type="checkbox" name="checkbox-0" class="check">Name 1</label> <label> <input type="checkbox" name="checkbox-0" class="check">Name 2</label> <label> <input type="checkbox" name="checkbox-0"...

ZF2 How to set with a custom Form Element

forms,zend-framework2,checked,custom-element

You have two options: a) Backend: The attributes array must contain a 'value' set to the only element of the values available, that's the way to auto-check the radio input. With your example, it would be: $this->add( [ 'type' => 'Member\Form\Element\OriginalLanguageIsoRadio', 'name' => 'original_language_iso', 'options' => [ 'label' => 'original_language_iso'...

How can I simplify that code (jquery) (radio button)

jquery,hide,show,checked

Easy. But I must admit that I'd probably change a lot more (e.g. use a class instead of show()/hide(), less IDs, a proper function, etc.), but as that's all you've provided us with. And using event delegation via on removes the often required domReady call and allows to reuse the...

Keep the check in checkbox on page reload

php,checkbox,checked

You are posting an array of checkboxes and only testing if the array was set. Change your check to this to test if an actual value was posted : if(isset($_POST['check']) && in_array($c, $_POST['check'])){ echo 'checked="checked"'; } ...

Checkbox is checked or not in mvc

jquery,model-view-controller,checkbox,checked

Solution 1: You need to use .length for checked elements. if($("#Baruc:checked").length){ //checkbox is checked } Solution 2: also you can use .is() method with :checked selector: if($("#Baruc").is(":checked")){ //checkbox is checked } ...

Changing check attribute of jquery dom items in a variable array

jquery,list,dom,checkbox,checked

Try to use .prop() instead of .attr() to set the checked state of form elements, from the docs: As of jQuery 1.6, the .attr() method returns undefined for attributes that have not been set. To retrieve and change DOM properties such as the checked, selected, or disabled state of form...

MVC Razor RadioButtonFor: How to have NO preset @checked?

asp.net-mvc,razor,checked,radiobuttonfor

I was able to reproduce this with my own testing. The reason the last radio button is selected is because of your checked = false. The presence of the checked attribute means that the radio button is supposed to be checked. You could have something like checked = "casey-is-awesome!" and...

PHP compare 2 arrays from database and checkbox=checked if any of the values are found

php,mysql,arrays,checkbox,checked

Use in_array like you did in your comment, you have to pass it the correct array though: $codesSelected = explode(', ', $pi_row['appsSelected']); for ($i = 0; $i < count($appliances); $i++) { if (in_array($appliances[$i], $codesSelected)) { echo '<li><input type="checkbox" checked="checked" value="' . $appliances[$i] . '" name="applianceCheckbox[]">' . $appliances[$i] . '</input></li><br/>'; }...

Set checked attribute in Web Forms

c#,asp.net,checkbox,webforms,checked

As per my knowledge, CheckBox should be equal to either true or false and not checked or empty. Try changing it and revert if problem still occurs. Hope i helped. checked="<%#Convert.ToBoolean(DataBinder.Eval(Container.DataItem, "IsOperationPerformed")) ? TRUE : FALSE%>" ...

How to replace checkbox with an image using a label with no id

html,css,checkbox,checked

You can add an extra span inside the label but after the input and use the pseudo-element on that label { display: inline-block; cursor: pointer; position: relative; font-size: 13px; top: 0; right: -30px; width: 16px; } label span:before { content: ""; display: inline-block; width: 16px; height: 16px; margin-right: 10px; position:...

How can I have a visually active (checked), disabled toggle button in Bootstrap?

css,twitter-bootstrap,checkbox,checked,disabled-control

Any .btn element with .disabled will have its box-shadow removed by precedence. You can change that by adding your own simple style to be applied: .btn.disabled.active{ box-shadow: inset 0 3px 5px rgba(0,0,0,.275); } Bootply Change the box-shadow parameters to fit your needs....

Javascript set checkbox checked between selected values

javascript,checkbox,checked

I found it. What I should've done was this instead of if(elem.options[elem.selectedIndex].value == t) { times[i].checked = true; } i changed to if(startTime <= times[i].value && stopTime >= times[i].value && elem.options[elem.selectedIndex].value == t) { times[i].checked = true; } ...

Checkbox checked appears unchecked

jquery,checkbox,jquery-ui-dialog,checked

You should be using .prop() instead of .attr(). From the jQuery documentation: According to the W3C forms specification, the checked attribute is a boolean attribute, which means the corresponding property is true if the attribute is present at all—even if, for example, the attribute has no value or is set...

:checked selector not working

html,css,input,radio,checked

You missed :before CSS: input[type=radio]:checked ~ label:before { content:""; background-image: url("../img/radio-btn-checked.png"); font-size: 30px; text-align: center; line-height: 18px; } ...

How do I use :checked on radio buttons

css,wordpress,radio-button,checked

The problem is that you can't target the image or the label which you had replaced the radio button with. You can either: 1) Use JavaScript to change things (targeting parentNode) upon radio button click/change 2) Change the HTML markup if it is able to solve your problem, and apply...

Perl: safely make hash from list, checking for duplicates

perl,list,hash,duplicates,checked

Quick way to check that no keys were duplicate would be count the keys and make sure they are equal to half the number of items in the list: my @a = ...; my %h = @a; if (keys %h == (@a / 2)) { print "Success!"; } ...

Why FileNotFoundException is CheckedException?

java,exception,checked

Exceptions always encountered at runtime only, Difference is made when a exception is handled. Checked or unchecked means whether it is forced to handle at compile time or it will only be identified when it is encountered at runtime. If an exception is checked means compiler has way to identify...

Checkbox checked value binding

checkbox,knockout.js,checked

Your binding should return true, so change it to this - <input type="checkbox" data-bind="attr: { value: person.id}, checked: $root.chosenPerson() === $data"> Where chosenPerson is equal to the context of the input element. If the element is not within the context of a person, just do <input type="checkbox" data-bind="attr: { value:...