I have a set of checkboxes on my web page. On Save, I serialize and POST the form.
<div>
<label for="ViewAsWebpage">
{{#if this.ViewAsWebpage}}
<input type="hidden" id="ViewAsWebpage" name="ViewAsWebpage" value="true"/>
<input type="checkbox" class="enable-checkbox" checked />
{{else}}
<input type="hidden" id="ViewAsWebpage" name="ViewAsWebpage" value="false"/>
<input type="checkbox" class="enable-checkbox" />
{{/if}}
<span>View as Webpage</span>
</label>
</div>
Using the above code:
- on GET – the checkboxes are checked/unchecked based on the property
ViewAsWebpage - on POST – whatever the user selects should be posted.
But when I POST, it is not sending the correct values. Can someone pls suggest the right way to do this?
Your
<input type="checkbox">elements are missingnameattributes, so they won’t correspond to request parameters when you post the form.