Page 1 of 2

Parsing my data ... I cannot get Appery to display what the User has chosen...

Posted: Sat Jul 26, 2014 2:47 pm
by Alex Van Name

var checkedItems = '{"NGSS":[]}';
// I wanted to call the checkedItems object something I could recognize

var checkedItems = jQuery('[dsid="checkboxgroup"] input[type="checkbox"]:checked');
console.log("Checked items count = " + checkedItems.length);

for(var i = 0; i < checkedItems.length; i++){
var checkedItem = jQuery(checkedItems);
var checkedText = checkedItem.closest("span").find("label").text();
var checkedValue = checkedItem.val();

Code: Select all

 console.log("checkedItem[" + i + "] = " + checkedValue); 
 console.log("checkedItem[" + i + "] = " + checkedText); 

 //The console part works great! 

 checkedItems.push({text: checkedText, value: checkedValue}); 

};

localStorage.setItem("checkedItemsLSV", JSON.stringify(checkedItems));
var checkedItemsLSVValue = localStorage.getItem("checkedItemsLSV");
var stringToUser = checkedItemsLSVValue;

// can't get Appery element "localstorageNGSS" to show the user the list...

var obj = JSON.parse(checkedItems);

for(var i = 0; i < checkedItems.length; i++){
document.getElementById("demo").innerHTML =
obj.NGSS.text + " " + obj.NGSS.value;
}
Appery("localstorageNGSS").text(obj);


Parsing my data ... I cannot get Appery to display what the User has chosen...

Posted: Sat Jul 26, 2014 5:56 pm
by obullei

Hello!

Could you explain how you want this option to work


Parsing my data ... I cannot get Appery to display what the User has chosen...

Posted: Sun Jul 27, 2014 1:32 am
by Alex Van Name

The goal is to confirm that the user wants the checked standards. I have this object storing text and values . It is pushed with new data for each checkbox checked and then stringified into a local storage variable called checkeditemsLSV. I want to be able to have the data parsed into individual text that can be displayed so the user can confirm the checked standards they select. I also want to read elements of the array and I don't know how to read the elements of the array.


Parsing my data ... I cannot get Appery to display what the User has chosen...

Posted: Mon Jul 28, 2014 4:32 am
by Yurii Orishchuk

Hi Alex,

You can use following code for these goals:

pre

localStorage&#46;setItem("checkedItemsLSV", JSON&#46;stringify(checkedItems));
var checkedItemsLSVValue = localStorage&#46;getItem("checkedItemsLSV");
var stringToUser = checkedItemsLSVValue;

var outText = "";

for(var i = 0; i < checkedItems&#46;length; i++){
outText += checkedItems&#46;text + " " + checkedItems&#46;value + "
";
}

&#47;&#47;Note you should replace "labelName" with your label name&#46;
Apperyio("labelName")&#46;text(outText);

/pre

Regards.


Parsing my data ... I cannot get Appery to display what the User has chosen...

Posted: Mon Jul 28, 2014 6:08 pm
by Alex Van Name

Wow Yurii , such a nice simple way to do this! Thank you !


Parsing my data ... I cannot get Appery to display what the User has chosen...

Posted: Tue Jul 29, 2014 1:05 am
by Alex Van Name

can't get the code to function...

http://appery.io/app/mobile-frame?src...

var checkedItemz = [];
//Note you need replace "mobilecheckboxgroup_38" with your checkboxlist component name.
var checkedItemz = jQuery('[dsid="checkboxgroup"] input[type="checkbox"]:checked');
//Iterate through checked items.
for(var i = 0; i < checkedItemz.length; i++){
var checkedItem = jQuery(checkedItemz);
var checkedText = checkedItem.closest("span").find("label").text();
var checkedValue = checkedItem.val();
//Just out this value to browser console. Please check out it to see results.
console.log("checkedItem[" + i + "] = " + checkedValue);
//Here you can use "checkedValue" JS variable as you need.
checkedItemz.push({text: checkedText, value: checkedValue});
}
localStorage.setItem("checkedItemsLSV", JSON.stringify(checkedItemz));

var checkedItemsLSVValue = localStorage.getItem("checkedItemsLSV");

var outText = "";
for(var i = 0; i < checkedItemz.length; i++){
outText += checkedItemz.text + " " + checkedItemz.value + "";
}
//Note you should replace "labelName" with your label name.
Apperyio("label_NGSS").text(outText);


Parsing my data ... I cannot get Appery to display what the User has chosen...

Posted: Tue Jul 29, 2014 9:12 pm
by Yurii Orishchuk

Hi Alex,

Please specify how we can test your app and see problem with this code.

Regards.


Parsing my data ... I cannot get Appery to display what the User has chosen...

Posted: Tue Jul 29, 2014 9:50 pm
by Alex Van Name

i put the public link above

thank you for your help


Parsing my data ... I cannot get Appery to display what the User has chosen...

Posted: Tue Jul 29, 2014 10:01 pm
by Yurii Orishchuk

Alex,

I've seen you link, and able to open it..

But there is lot of things in your app.

You need specify steps to reproduce your problem.

Regards.


Parsing my data ... I cannot get Appery to display what the User has chosen...

Posted: Tue Jul 29, 2014 10:08 pm
by Alex Van Name

oh i see

well, after logging in, I have the person CREATE A NEW LESSON, then I skip the first page of this process, and go to the NEXT PAGE. This brings you to NGSS page. Then I do the actions that make the error by clicking on the drop down menu, clicking on 2 or more check boxes, and then pressing the SAVE button.