ACC: Web App Data storage of Checkbox data | Community
Skip to main content
bryceh57660644
Level 2
June 1, 2020
Solved

ACC: Web App Data storage of Checkbox data

  • June 1, 2020
  • 3 replies
  • 5691 views

(Updated)

Upon reviewing everything, the data is being stored properly when I change the type from checkbox to text, so I think it is about the way I am saving the checkbox data.

(picture below should have a row under language for Online Booking, and it does not.)

 

I am creating my first web app landing page in ACC and while I have all of my text input fields working, I am struggling to get the checkboxes to relay the data I want.

In the HTML, I have set the values - if checked - to be = 1

 

 

I was also looking into a data transfer issue, but the variables used in the web app, the HTML and data schema all line up:

 

Any help would be greatly appreciated.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Manoj_Kumar

Hello @bryceh57660644 

If you to store the checkbox value and treat it as a boolean then here is the code

 

HTML

<input type="checkbox" id="agree" label="agree">

JS

if(document.getElementById('agree').checked){ document.controller.setValue('/ctx/vars/CHECKBOX_VARIABLE',"true"); } else{ document.controller.setValue('/ctx/vars/CHECKBOX_VARIABLE',"false"); }

 

Let me know if that helps

3 replies

Manoj_Kumar
Community Advisor
Community Advisor
June 1, 2020

Hello @bryceh57660644 

Are you trying to preload the data and have the checkbox checked automatically with the variable data?

If yes, What you can do is

<input type="checkbox" name="name" <% if(ctx.vars.VARIABLE_NAME =='YOUR_VALUE' ) { %>checked <% } %>>
Manoj     Find me on LinkedIn
bryceh57660644
Level 2
June 1, 2020
No, I want them to check the box. I am just not 100% sure how to get that data in the schema I guess.
bryceh57660644
Level 2
June 1, 2020

@_manoj_kumar_ no I am looking to have the recipient check the box of the service they are interested in.  Once they check the items they are interested in, and hit submit, I want the form to submit a Yes or 1 response to the data schema.  I have the fields as type="boolean" at the moment.

Manoj_Kumar
Community Advisor
Community Advisor
June 1, 2020
I don't think Type="boolean" is valid. If you want to have something like that you may want to use a checkbox instead. If the checkbox is checked then you will consider it as 1 or Yes. If the check is unchecked then you can consider is 0 or NO
Manoj     Find me on LinkedIn
Manoj_Kumar
Community Advisor
Manoj_KumarCommunity AdvisorAccepted solution
Community Advisor
June 2, 2020

Hello @bryceh57660644 

If you to store the checkbox value and treat it as a boolean then here is the code

 

HTML

<input type="checkbox" id="agree" label="agree">

JS

if(document.getElementById('agree').checked){ document.controller.setValue('/ctx/vars/CHECKBOX_VARIABLE',"true"); } else{ document.controller.setValue('/ctx/vars/CHECKBOX_VARIABLE',"false"); }

 

Let me know if that helps

Manoj     Find me on LinkedIn