Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

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

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);

obullei
Posts: 0
Joined: Thu Jun 05, 2014 12:17 am

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

Hello!

Could you explain how you want this option to work

Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

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

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.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

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

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.

Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

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

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

Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

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

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);

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

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

Hi Alex,

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

Regards.

Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

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

i put the public link above

thank you for your help

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

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

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.

Alex Van Name
Posts: 0
Joined: Mon Jun 30, 2014 7:36 pm

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

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.

Return to “Issues”