[Solved] selected and deselected checkbox in Swift

try this below code if let button = sender as? UIButton { if button.isSelected { // set selected button.isSelected = true } else { // set deselected button.isSelected = false } } For shorthand, try this if let button = sender as? UIButton { button.isSelected = !button.isSelected } 1 solved selected and deselected checkbox in … Read more

[Solved] How to disable / enable checkbox base on select (option) value [closed]

All you have to do is listen to the select and react when it changes. // Listen to the change of the <select> element $(“#typeofworkday”).on(“change”, function() { // Check the option value for “ferie” and disable the checkbox if ($(this).val() === “ferie”) { $(“#check1”).attr(“disabled”, “disabled”); // For all other options, enable the checkbox } else … Read more

[Solved] Javascript add value if checkbox is checked

Solution that changes based on checkbox state: var chap7 = document.getElementById(‘chap7’), post = document.getElementById(‘post’), printed = document.getElementById(‘printed’); printed.addEventListener(‘change’, function() { var quantity = parseInt(chap7.value, 10); post.value = printed.checked ? quantity * 3.5 : quantity; }, false); chap7.addEventListener(‘change’, function() { post.value = parseInt(this.value, 10); }); <p> <label for=”hours”>Learn JavaScript the Hardy Way’ – Complete e-book (Printed)</label> … Read more

[Solved] Display alert if checkbox isn’t checked on button click [closed]

You need to capture the click event of your button and then check whether the checkbox is clicked or not. If not, you can send the alert and return false (be sure to do this otherwise the form will be submitted anyway). $(‘#reset’).click(function () { if (!$(‘#confirm’).is(‘:checked’)) { alert(‘not checked’); return false; } }); jsFiddle … Read more

[Solved] Save CheckBox in Android Studio

It is keeping the same state because you are using the same shared preference for both checkboxes. Also you can use only one editor public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final CheckBox checkBox = (CheckBox) findViewById(R.id.checkBox); final CheckBox checkBox2 = (CheckBox) findViewById(R.id.checkBox2); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); final … Read more