Checking the values of Checkboxes made after a Database request returned a list, with the Checkboxes embedded in a drop-
My page is querying the "Database for Life Science Standards" that relate to "Structure and Function". The request successfully brings the values back to a LABEL that is EMBEDDED in a CheckBoxGroup.
What happens... the user gets the list of possibilities. The user can check the little check boxes. However, I cannot find a way to read what the user has checked.
I have looked online and I found this code from
https://getsatisfaction.com/apperyio/...:
var arr = new Array();
arr = Appery("guardianCheckBox").find(":checked").map(function(el) {
return el.val();
});
if (arr.length == 0) {
alert("Please select a guardian!");
return;
}
if (arr.length 2) {
alert("Please select only 2 guardians!");
} else {
var items = ['selectedGuardian', 'selectedGuardian2'];
$.each(arr, function(i, value){
localStorage.setItem(items, value);
});
addChild.execute();
}
// restore from localStorage
var items = ['selectedGuardian', 'selectedGuardian2'];
$.each(arr, function(i, key){
var value = localStorage.getItem(key);
Appery("guardianCheckBoxList")
.find("input[value='" + value + "']:first")
.prop('checked', 'checked')
.refresh();
});
var arr = new Array();
Appery("checkboxgroup").find(":checked").each(function(){
arr.push($(this).val());
});
=============================
I modified it for my purposes like this:
=============================
var arr = new Array([]);
arr = Appery("checkbox2_Standard").find(":checked").map(function(el) {
return el.val();
});
if (arr.length === 0) {
alert("Please select a standard!");
return;
}
if (arr.length 2) {
alert("Please select only 2 standards maximum.");
} else {
var items = ['NGSS_standard1', 'NGSS_standard2'];
$.each(arr, function(i, value){
localStorage.setItem(items, value);
});
addChild.execute();
}
// restore from localStorage
var items = ['NGSS_standard1', 'NGSS_standard2'];
$.each(arr, function(i, key){
var value = localStorage.getItem(key);
Appery("checkbox2_StandardList")
.find("input[value='" + value + "']:first")
.prop('checked', 'checked')
.refresh();
});
Appery("checkboxgroup").find("input:checked").each(function(){
alert($(this).text());
});
I understand conceptually that an array would need to be created when more than one standard is checked. With each new "Check" , an item would be added to the array. This code limits the number of standards to 2, which is close to what I want to do. I want to take all the "checked" boxes and store the results in a growing database. This way, at the end of the app, the user can print these "Standards" later in a final document. I am using the check boxes so the user doesn't need to type all the text for each standard.
FIREFOX browser is giving me these errors:
Errors on login:
Use of Mutation Events is deprecated.
Use MutationObserver instead. target-script-min.js:1271
ReferenceError: jsPDF is not defined pdfJavafromWeb.js:2
ReferenceError: Downloadify is not defined download_java_scriptprint.js:3
ReferenceError: Downloadify is not defined showpdf.js:3
and after that...
Errors when trying to use the checkboxes and javascript I modified:
----------------------------------------TypeError: doc.fromHTML is not a function JavaScript3.js:14
Empty string passed to getElementById(). jquery.mobile-1.4.0.js:14607
Use of getPreventDefault() is deprecated. Use defaultPrevented instead. jquery-1.9.1.js:3346
Use of getAttributeNode() is deprecated. Use getAttribute() instead. jquery-1.9.1.js:2514
TypeError: el.val is not a function
Here are pictures of my database, the element names , and the GUI in use.
Thank you for showing such care and mercy. I am doing my best to read and understand the previous posts. I know this question was asked but I am missing some key concepts of how the check boxes should work. I remember BASIC from the 1980s and I am trying to apply this knowledge to javascript. not bad, but a different animal for programming.
Can I better organize my files in the database? should I?
I know everyone's app logic is different, but I am trying to make this easy for the user, and what is easy for the user, is more difficult for the programmer.
Thank you thank you 1000x!
Alex