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

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

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.

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

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

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.

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

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

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?

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

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

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...

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

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

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

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

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

Hi Alex,

Please give us your app public link,

and describe steps to reproduce this problem.

Thanks & regards.

Return to “Issues”