php - Checkboxes with FormData.Append -


i using javascript formdata.append pass values php file, cannot check boxes working. example

html

<input type="checkbox" name="xxx" value="xxx" /><label>xxx option</label> 

js

formdata.append( 'xxx', $('input[name=xxx]').val()); 

php

if (isset($_post['xxx'])) {    echo "checked!";} 

whether check box or not, response - checked!

or php

$xxx= $_post['xxx']; 

the var $xxx shows value xxx whether checked or not.

how can pass checkboxes using method can differentiate if checkbox ticked or not!

try using

document.getelementsbyname('xxx')[0].checked

to check status of whether it's checked or not.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -