Skip to content

checkbox always sends value #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
issaev opened this issue May 16, 2016 · 4 comments
Closed

checkbox always sends value #31

issaev opened this issue May 16, 2016 · 4 comments
Labels

Comments

@issaev
Copy link

issaev commented May 16, 2016

When submitting a checkbox, it always behaves as checked - ie the "value" attribute is sent

@iteles
Copy link
Member

iteles commented May 16, 2016

@issaev Do you have a link to your code to share so the dwyl community could try to help you debug?

@dmstan
Copy link

dmstan commented Jul 6, 2016

I have the same issue, the checkbox is always sent "on". Any progress on this?

@mckennapsean
Copy link
Collaborator

mckennapsean commented Jul 19, 2016

In form-submission-handler.js, it grabs every form element's .value attribute. Unfortunately, for checkboxes, this is always "on" and we need the .checked attribute instead. Fixing the code now, will close once done.

@anitaleung
Copy link

Hi, not entirely sure if this is the right place to post this but this fix does not catch the usecase where there is a single checkbox.

I suspect this is the reason issue #265 was brought up as well.

A potential solution could be this when we collect form data:

// if checkbox, then get the checked value
if (element.type == 'checkbox') {
     formData[name] = ""; 
     if (element.checked) {
          formData[name] = element.value;
     } 
} 

where if the checkbox is checked then the sheet's cell would show the checkbox value, otherwise is blank.

Thanks for all your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants