samedi 22 septembre 2018

Saving multiple checkbox values and a check all checkbox value with localstorage

I have set up localstorage to save the value of my checkboxes and have a "check all" and "uncheck all" function. I am trying to implement a way to show only the checked items when a specific checkbox, separate from the "check all" group of checkboxes, is checked. The problem I am having is saving that checkbox value into localstorage. I see in the console that my formValues checkboxes as well as my separate showHide checkbox are saved in localstorage. I am just getting stumped at the show and hide functionality working with the check all functionality. I realize this may be confusing. Any help or direction is appreciated!

Here is a codepen

var formValues = JSON.parse(localStorage.getItem("formValues")) || {};
var showHide = JSON.parse(localStorage.getItem("showHide")) || {};
var $checkboxes = $("#checkbox-container input.drug");
var $button = $("#checkbox-container .checkall");
var $show = $("#checkbox-container #hideDrugs");

if ($show.prop('checked', true)) {
  $('.Rtable-row.hidden-print').fadeOut(200);
} else {
  $('.Rtable-row.hidden-print').fadeIn(200);
}
$show.on("change", function() {
  if (this.checked) {
    $('.Rtable-row.hidden-print').fadeOut(200);
  } else {
    $('.Rtable-row.hidden-print').fadeIn(200);
  }
});

function allChecked() {
  return $checkboxes.length === $checkboxes.filter(":checked").length;
}

function updateButtonStatus() {
  $button.text(allChecked() ? "Uncheck all" : "Check all");
  $button.filter(function() {
    if ($(this).text() == 'Check all') {
      $show.prop('checked', false);
    } else {}
  })
}

function handleButtonClick() {
  $checkboxes.prop("checked", allChecked() ? false : true);
}

function updateStorage() {
  $checkboxes.each(function() {
    formValues[this.id] = this.checked;
    if (this.checked) {
      $(this).parents('.Rtable-row').removeClass('hidden-print');
    } else {
      $(this).parents('.Rtable-row').addClass('hidden-print');
    }
  });
  $show.each(function() {
    showHide = this.checked;
    if (this.checked) {
      console.log('checked')
    } else {
      console.log('unchecked')
    }
  });

  formValues["buttonText"] = $button.text();
  localStorage.setItem("formValues", JSON.stringify(formValues));
  localStorage.setItem("showHide", JSON.stringify(showHide));
}

$button.on("click", function() {
  handleButtonClick();
  updateButtonStatus();
  updateStorage();
});

$show.on("change", function() {
  updateStorage();
});
$checkboxes.on("change", function() {
  updateButtonStatus();
  updateStorage();
});

// On page load
$.each(formValues, function(key, value) {
  $("#" + key).prop("checked", value);
});
$show.prop('checked', showHide.value);
$button.text(formValues["buttonText"]);



How can I set checkbox list items as Checked by DEFAULT in AlertDialog android?

I need to show a list of checkbox list items as CHECKED in ALERTDIALOG by default(when the alertbox pops up) in android.

This is my code,

 final String[] items = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
    final List<String> itemlist = Arrays.asList(items);


    AlertDialog dialog = new AlertDialog.Builder(this)
            .setTitle("Working days")
            .setMultiChoiceItems(items, seletedvaluesbool, new DialogInterface.OnMultiChoiceClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int indexSelected, boolean isChecked) {

                    if (isChecked) {
                        // If the user checked the item, add it to the selected items

                    } else if (seletedItems.contains(indexSelected)) {
                        // Else, if the item is already in the array, remove it

                    }
                }
            }).setPositiveButton("OK", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {

                }
            }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    //  Your code when user clicked on Cancel
                }
            }).create();
    dialog.show();

    }

When the dialog pops up, I need to show few items as Checked by default. I tried below code for that but it's not working.

    ListView lv = ((AlertDialog) dialog).getListView();
    dialog.getListView().setSelection(0); //To set the 0th position as checked

Any help would be great. Thanks in advance.




how to select check box in appium , when there is no unique id/class name?

How to select the checkbox in the below screenshot? enter image description here

Tried below poossibilites but not working. driver.findElementByXPath("//android.widget.TextView[@text='World Music']").click(); driver.findElementByXPath("//android.widget.TextView[@index='11']").click(); driver.findElementByAndroidUIAutomator("text(\"World Music\")").click();




vendredi 21 septembre 2018

How to Use Checkbox to Populate Tableview in JavaFX

In this Attached Picture I want to Populate Table view with selected checkbox field only. How to Implement this. And How the SQL query will come ?? And Can I print the Populated data in Jasper report ??

Image of UI




i can't understand why my code doesn't work can someone please check it out? I am very new (JavaScript)

this is the script

<script>
var a,b,c;
a = document.getElementById("myCheck1");
b = document.getElementById("myCheck2");
c = document.getElementById("myCheck3");

this function works only if the other one is a comment

function check() { 
if (a.checked == true)
document.getElementById("a").innerHTML="a true";
else
document.getElementById("a").innerHTML="a false";

if (b.checked == true)
document.getElementById("b").innerHTML="b true";
else
document.getElementById("b").innerHTML="b false";

if (c.checked == true)
document.getElementById("c").innerHTML="c true";
else
document.getElementById("c").innerHTML="c false";
}

this function doesnt work and make the other one not to work

function clickOnB() {
if (a.checked == true || c.checked == true)
a.checked = false;
c.checked = false;
else
b.checked = true;
}
</script>

this is the body

Checkbox1: <input type="checkbox" id="myCheck1" value="a"/>
Checkbox2: <input type="checkbox" id="myCheck2" onclick="clickOnB() " 
value="b"/>
Checkbox3: <input type="checkbox" id="myCheck3" value="c"/>
<p id="a"></p>
<p id="b"></p>
<p id="c"></p>
<button type="button" onclick="check()" />




jeudi 20 septembre 2018

how to set checkbox checked in JSGRID?

I tried the code below but it does not work. Could someone please help me?

  { 
name: "MyField", 
type:"checkbox", 
insertTemplate: function() {
    var $result = jsGrid.fields.checkbox.prototype.insertTemplate.call(this);
    $result.prop("checked", true);
    return $result;
} 
}




Is it a WCAG 2.0 AA violation if the label of a checkbox is a hyperlink?

I have 4 check boxes and labels corresponding to each is a hyperlink which takes user to the start page of that particular topic. So basically selecting the checkbox has a different function while activating the link performs another function.I know it is not a recommended practice, but can I mark it against any WCAG criteria?

enter image description here