Page 3 of 3

Checking the values of Checkboxes made after a Database request returned a list, with the Checkboxes embedded in a drop-

Posted: Fri Jul 25, 2014 3:03 am
by Alex Van Name

Thanks Yurii, I do see this, that is ok, but my goal is to store the data in a local storage variable, which is in the checkedItemsLSV, but how can I repost it on the screen so the user can see?

I want to make the user aware of what they have checked.

so that the button reads the data, saves it locally, and then I can re-display this to the user (not just to me privately in the console).

I want to have the results appear in a box below the drop down checkboxgroup.


Checking the values of Checkboxes made after a Database request returned a list, with the Checkboxes embedded in a drop-

Posted: Fri Jul 25, 2014 4:22 am
by Yurii Orishchuk

Alex,

Currently it's hard to help you at all, cause of we don't know how you would like to display this information to user.

But here is simple way do it:

  1. Add to your page(where you need) label component.

  2. Use following code to fill the label with information stored in "checkedItemsLSV" lsv:

    pre

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

    var stringToUser = checkedItemsLSVValue;

    //Here you can change "stringToUser" in accordance with you needs.

    //Note you need replace "labelName" with your label component(from 1st step) name.
    Appery("labelName").text(stringToUser);

    /pre

    Regards.


Checking the values of Checkboxes made after a Database request returned a list, with the Checkboxes embedded in a drop-

Posted: Fri Jul 25, 2014 2:50 pm
by Alex Van Name

Thank you Yurii, I will try this out.


Checking the values of Checkboxes made after a Database request returned a list, with the Checkboxes embedded in a drop-

Posted: Fri Jul 25, 2014 4:34 pm
by Alex Van Name

ok i tried the code, and now my program is stuck in a loop, the browser is crashing when i click the SAVE NGSS button.

this is the code...

-----------------------------------------------------

var checkedItems = [];

//Note you need replace "mobilecheckboxgroup_38" "checkbox2_Standard" with your checkboxlist component name.
var checkedItems = jQuery('[dsid="checkboxgroup"] input[type="checkbox"]:checked');
console.log("Checked items count = " + checkedItems.length);

//Iterate through checked items.
for(var i = 0; i < checkedItems.length; i++){
var checkedItem = jQuery(checkedItems);
var checkedText = checkedItem.closest("span").find("label").text();
var checkedValue = checkedItems.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.
checkedItems.push(
{
text: checkedText,
value: checkedValue
});
}

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

//Here you can change "stringToUser" in accordance with you needs.

//Note you need replace "labelName" with your label component(from 1st step) name.
Appery("NGSS_LSV").text(checkedItemsLSVValue);

-----------------------------------------------------

I can't debug in the browser, because the browsers Chrome and Firefox both crash.

What is going wrong?


Checking the values of Checkboxes made after a Database request returned a list, with the Checkboxes embedded in a drop-

Posted: Fri Jul 25, 2014 6:00 pm
by Alex Van Name

this is the javascript console:

Checked items count = 2 loginScreen.js:2113

checkedItem[0] = 53c993cbe4b0b3c828cb8f97 loginScreen.js:2121
checkedItem[1] = 53c993cbe4b0b3c828cb8f98 loginScreen.js:2121

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined
$.off.on.click loginScreen.

js:2119

The list of checkboxes doesn't scroll down nicely either...


Checking the values of Checkboxes made after a Database request returned a list, with the Checkboxes embedded in a drop-

Posted: Fri Jul 25, 2014 6:04 pm
by Alex Van Name

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined jquery-1.9.1.js:2208

jQuery.fn.extend.val jquery-1.9.1.js:2208
$.off.on.click loginScreen.js:2119
jQuery.event.dispatch jquery-1.9.1.js:3074
elemData.handle jquery-1.9.1.js:2751


Checking the values of Checkboxes made after a Database request returned a list, with the Checkboxes embedded in a drop-

Posted: Mon Jul 28, 2014 1:47 am
by Yurii Orishchuk

Hi Alex,

Please give us your app public link,

and describe steps to reproduce this problem.

Thanks & regards.