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-

On the right side, it says "SET DETAIL CONTENT".

Somehow this looks very bad on iphone...

After the user logs on successfully, the main menu appears in this space. I figured this out today from a previous support question. Someone else had the same problem as me. Thanks!

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-

How to set property of a LABEL to a CHECKED ITEM or CHECKED ITEMS based on the code from before...I want to store all the checked items into something that i can return to the user.

I want to tell the USER, hey, you checked these standards. Then I want to save these in a new database using the CREATE SERVICE.

Can I save these values to local variables and show the user what they have chosen, so they can modify or update the standards they chose?

Thanks for your help!

//Note you need replace "checkbox2_Standard" with your checkboxlist component name.
var checkedItems = jQuery('[dsid="checkbox2_Standard"] 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 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.
}

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-

How to set property of a LABEL to a CHECKED ITEM or CHECKED ITEMS based on the code from before...I want to store all the checked items into something that i can return to the user.

I want to tell the USER, hey, you checked these standards. Then I want to save these in a new database using the CREATE SERVICE.

Can I save these values to local variables and show the user what they have chosen, so they can modify or update the standards they chose?

Thanks for your help!

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,

At first - it seem you are using "checkbox component" instead of "checkboxgroup component" please check it out.

To store checked items into LSV you can use following code:

pre

var checkedItems = [];

&#47;&#47;Note you need replace "mobilecheckboxgroup_38" with your checkboxlist component name&#46;
var ckeckedItems = jQuery('[dsid="mobilecheckboxgroup_38"] input[type="checkbox"]:checked');
console&#46;log("Checked items count = " + ckeckedItems&#46;length);
&#47;&#47;Iterate through checked items&#46;
for(var i = 0; i < ckeckedItems&#46;length; i++){
var checkedItem = jQuery(ckeckedItems);

Code: Select all

 var checkedText = checkedItem&#46;closest("span")&#46;find("label")&#46;text(); 

 var checkedValue = checkedItem&#46;val(); 
 &#47;&#47;Just out this value to browser console&#46; Please check out it to see results&#46; 
 console&#46;log("checkedItem[" + i + "] = " + checkedValue); 
 &#47;&#47;Here you can use "checkedValue" JS variable as you need&#46; 

 checkedItems&#46;push({text: checkedText, value: checkedValue}); 

};

localStorage&#46;setItem("checkedItemsLSV", JSON&#46;stringify(checkedItems));

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

Thanks Yurii,

I was working on printing code, but I will work on this again tomorrow.

I want to organize all the data and then store the data in a database and then call it back ... and print the data in a standardized template.

I was reading about pdfs, but I find it very confusing to use the java script.

I downloaded jsPDF and pdfmake but I am getting errors in places I don't understand. :-(

I will try more tomorrow.

Thank you

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, so I can't seem to get this code to work

I see what you mean about the "checkbox component" vs the "CheckboxGroup component", but there doesn't seem to be a difference for my purposes. Or is there?

I am having trouble implementing the code to show the user what they have chosen.

I used...

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

var checkedItems = [];
//Note you need replace "mobilecheckboxgroup_38" "checkbox2_Standard" with your checkboxlist component name.
var ckeckedItems = jQuery('[dsid="checkbox2_Standard"] 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 = 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.
checkedItems.push({text: checkedText, value: checkedValue});
}
localStorage.setItem("checkedItemsLSV", JSON.stringify(checkedItems));

Image Image Image Image

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

the "add JS" is this return'{"TopicChosen":"'+value+'"}';

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

I appreciate your gift, the javascript above stores the data into "checkedItemsLSV", a local variable which I have created.

so I attempted to set the properties of a LABEL to the localvariable checkedItemsLSV, but the computer makes the label as ...

[]

so I don't understand where my problem or problems are happening.

Image

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-

Image

I changed the code a little from PLURAL "items" to SINGULAR "item", like this:

//Here you can use "checkedValue" JS variable as you need.
checkedItems.push({text: checkedText, value: checkedValue});
}
localStorage.setItem("checkedItemsLSV", JSON.stringify(checkedItems));

-- to --

//Here you can use "checkedValue" JS variable as you need.
checkedItem.push({text: checkedText, value: checkedValue});
}
localStorage.setItem("checkedItemsLSV", JSON.stringify(checkedItem));

and above is the screen. Can you help me? Why don't I see the checked standards for both? Only the second one is visible, but buried in an array or something.

Thank you !

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,

Nope, there is big diffrence between checkboxGroup component and checkbox component.

CheckBoxes - are inside the checkboxGroup component.

Please take a look on scren shot to understand this difference:

http://prntscr.com/461znj/direct

So you need back to your code and replace your "checkbox2_Standard" with checkboxGroup component(exactly the same as it mentioned in comment for the code).

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 have been reading about JSON and it seems like to make a JSON you are using STRINGIFY to build the object with each new "click".

I have also read that PARSE is used to break down the object that was created using stringify.

I guess now that this local storage variable is created, and it has this data packed, when I set a LABEL to this local storage variable no information is put into the LABEL.

var checkedItems = [];
//Note you need replace "mobilecheckboxgroup_38" 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 = 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.
checkedItem.push({text: checkedText, value: checkedValue});
localStorage.setItem("checkedItemsLSV", JSON.stringify(checkedItem));
}
=======================================================
now I would like to see the data, so I should parse the data? Is that correct?

localStorage.setItem("checkedItemsLSV", JSON.stringify(checkedItem));
JSON.parse(checkedItem);

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,

Nope, to see data in LSV you can do following:

1 Open chrome browser.

2 Run your app in this browser without frame.

3 Open internal browser debugger(F12).

4 Navigate to console tab.

5 Put in this console following code:

pre

console&#46;log(localStorage&#46;getItem("checkedItemsLSV"));

/pre

6 Press "Enter" to run this code in console.

7 You will get result.

See details: http://prntscr.com/46384m/direct

Regards.

Return to “Issues”