我目前面临一个问题,即将我的复选框值发布到我的php以更新查询。我目前正在使用ajax发布它,但似乎它将空数据发布到我的php端的GET函数。
为了发布我的复选框值,我有什么必须添加的吗?请指出。感谢
这是我的ajax代码:
<script>
$(document).ready(function(){
//File and text upload with formDATA function
$("form#form").submit(function(){
var formData = new FormData($(this)[0]);
$.ajax({
url:'masterItem.php',
type: 'POST',
data: formData,
async: false,
beforeSend: function(){
if(confirm('Are you sure to change the kiosks mode?'))
return true;
else
return false;
},
cache: false,
contentType: false,
processData: false
}).done(function () {
//do something if you want when the post is successfully
if(!alert('Form Had Successfully Inserted.')){document.getelementbyclassname('form').reset()}
}).fail(function () {
//if the post is failed show an error message if you want
alert('Some error occur. Please try again later.');
});
return false;
});
});
</script>
我的复选框代码示例:
<form action="" id="form" class="form">
<div class="anchor">
<ul>
<li>
<label><input type="checkbox" data-id="All Master" data-name="All Master" id="myCheckBox0" onchange="checkDisabled(testing);"/> All Kedai Kiosk On Master Mode</label>
<ul>
<li>
<label><input type="checkbox" data-id="Selangor" data-name="Selangor" id="myCheckBox1" onchange="checkDisabled(testing);"/> Selangor</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="1" data-id="Kiosk 1" data-name="Kiosk 1" id="myCheckBox2" onchange="checkDisabled(testing);"/> Kiosk 1 </label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="2" data-id="Kiosk 2" data-name="Kiosk 2" id="myCheckBox3" onchange="checkDisabled(testing);"/> Kiosk 2 </label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="5" data-id="Kiosk 5" data-name="Kiosk 5" id="myCheckBox4" onchange="checkDisabled(testing);"/> Kiosk 5 </label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="7" data-id="Kiosk 7" data-name="Kiosk 7" id="myCheckBox5" onchange="checkDisabled(testing);"/> Kiosk 7 </label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="8" data-id="Kiosk 8" data-name="Kiosk 8" id="myCheckBox6" onchange="checkDisabled(testing);"/> Kiosk 8 </label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="9" data-id="Kiosk 9" data-name="Kiosk 9" id="myCheckBox7" onchange="checkDisabled(testing);"/> Kiosk 9 </label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="10" data-id="Kiosk 10" data-name="Kiosk 10" id="myCheckBox8" onchange="checkDisabled(testing);"/> Kiosk 10</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="11" data-id="Kiosk 11" data-name="Kiosk 11" id="myCheckBox9" onchange="checkDisabled(testing);"/> Kiosk 11</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="12" data-id="Kiosk 12" data-name="Kiosk 12" id="myCheckBox10" onchange="checkDisabled(testing);"/> Kiosk 12</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="13" data-id="Kiosk 13" data-name="Kiosk 13" id="myCheckBox11" onchange="checkDisabled(testing);"/> Kiosk 13</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="14" data-id="Kiosk 14" data-name="Kiosk 14" id="myCheckBox12" onchange="checkDisabled(testing);"/> Kiosk 14</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="15" data-id="Kiosk 15" data-name="Kiosk 15" id="myCheckBox13" onchange="checkDisabled(testing);"/> Kiosk 15</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="16" data-id="Kiosk 16" data-name="Kiosk 16" id="myCheckBox14" onchange="checkDisabled(testing);"/> Kiosk 16</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="17" data-id="Kiosk 17" data-name="Kiosk 17" id="myCheckBox15" onchange="checkDisabled(testing);"/> Kiosk 17</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="18" data-id="Kiosk 18" data-name="Kiosk 18" id="myCheckBox16" onchange="checkDisabled(testing);"/> Kiosk 18</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="19" data-id="Kiosk 19" data-name="Kiosk 19" id="myCheckBox17" onchange="checkDisabled(testing);"/> Kiosk 19</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="20" data-id="Kiosk 20" data-name="Kiosk 20" id="myCheckBox18" onchange="checkDisabled(testing);"/> Kiosk 20</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="21" data-id="Kiosk 21" data-name="Kiosk 21" id="myCheckBox19" onchange="checkDisabled(testing);"/> Kiosk 21</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="22" data-id="Kiosk 22" data-name="Kiosk 22" id="myCheckBox20" onchange="checkDisabled(testing);"/> Kiosk 22</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="23" data-id="Kiosk 23" data-name="Kiosk 23" id="myCheckBox21" onchange="checkDisabled(testing);"/> Kiosk 23</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Putrajaya" data-name="Putrajaya" id="myCheckBox22" onchange="checkDisabled(testing);"/> Putrajaya</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="23" data-id="Kiosk 24" data-name="Kiosk 24" id="myCheckBox23" onchange="checkDisabled(testing);"/> Kiosk 24</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Kuala Lumpur" data-name="Kuala Lumpur" id="myCheckBox24" onchange="checkDisabled(testing);"/> Kuala Lumpur</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="25" data-id="Kiosk 26" data-name="Kiosk 26" id="myCheckBox25" onchange="checkDisabled(testing);"/> Kiosk 26</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="26" data-id="Kiosk 27" data-name="Kiosk 27" id="myCheckBox26" onchange="checkDisabled(testing);"/> Kiosk 27</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="27" data-id="Kiosk 28" data-name="Kiosk 28" id="myCheckBox27" onchange="checkDisabled(testing);"/> Kiosk 28</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="28" data-id="Kiosk 29" data-name="Kiosk 29" id="myCheckBox28" onchange="checkDisabled(testing);"/> Kiosk 29</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="29" data-id="Kiosk 30" data-name="Kiosk 30" id="myCheckBox29" onchange="checkDisabled(testing);"/> Kiosk 30</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="30" data-id="Kiosk 31" data-name="Kiosk 31" id="myCheckBox30" onchange="checkDisabled(testing);"/> Kiosk 31</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="31" data-id="Kiosk 32" data-name="Kiosk 32" id="myCheckBox31" onchange="checkDisabled(testing);"/> Kiosk 32</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="32" data-id="Kiosk 33" data-name="Kiosk 33" id="myCheckBox32" onchange="checkDisabled(testing);" /> Kiosk 33</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="33" data-id="Kiosk 34" data-name="Kiosk 34" id="myCheckBox33" onchange="checkDisabled(testing);"/> Kiosk 34</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Pahang" data-name="Pahang" id="myCheckBox34" onchange="checkDisabled(testing);"/> Pahang</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="35" data-id="Kiosk 35" data-name="Kiosk 35" id="myCheckBox35" onchange="checkDisabled(testing);"/> Kiosk 35</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="36" data-id="Kiosk 36" data-name="Kiosk 36" id="myCheckBox36" onchange="checkDisabled(testing);"/> Kiosk 36</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="37" data-id="Kiosk 37" data-name="Kiosk 37" id="myCheckBox37" onchange="checkDisabled(testing);"/> Kiosk 37</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="6" data-id="Kiosk 6" data-name="Kiosk 6" id="myCheckBox38" onchange="checkDisabled(testing);"/> Kiosk 6</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Perak" data-name="Perak" id="myCheckBox39" onchange="checkDisabled(testing);"/> Perak</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="38" data-id="Kiosk 38" data-name="Kiosk 38" id="myCheckBox40" onchange="checkDisabled(testing);"/> Kiosk 38</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="39" data-id="Kiosk 39" data-name="Kiosk 39" id="myCheckBox41" onchange="checkDisabled(testing);"/> Kiosk 39</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="40" data-id="Kiosk 40" data-name="Kiosk 40" id="myCheckBox42" onchange="checkDisabled(testing);"/> Kiosk 40</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="41" data-id="Kiosk 41" data-name="Kiosk 41" id="myCheckBox43" onchange="checkDisabled(testing);"/> Kiosk 41</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="42" data-id="Kiosk 42" data-name="Kiosk 42" id="myCheckBox44" onchange="checkDisabled(testing);"/> Kiosk 42</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Kedah" data-name="Kedah" id="myCheckBox45" onchange="checkDisabled(testing);"/> Kedah</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="43" data-id="Kiosk 43" data-name="Kiosk 43" id="myCheckBox46" onchange="checkDisabled(testing);"/> Kiosk 43</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="44" data-id="Kiosk 44" data-name="Kiosk 44" id="myCheckBox47" onchange="checkDisabled(testing);"/> Kiosk 44</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="45" data-id="Kiosk 45" data-name="Kiosk 45" id="myCheckBox48" onchange="checkDisabled(testing);"/> Kiosk 45</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="46" data-id="Kiosk 46" data-name="Kiosk 46" id="myCheckBox49" onchange="checkDisabled(testing);"/> Kiosk 46</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Pulau Pinang" data-name="Pulau Pinang" id="myCheckBox50" onchange="checkDisabled(testing);"/> Pulau Pinang</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="47" data-id="Kiosk 47" data-name="Kiosk 47" id="myCheckBox51" onchange="checkDisabled(testing);"/> Kiosk 47</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="48" data-id="Kiosk 48" data-name="Kiosk 48" id="myCheckBox52" onchange="checkDisabled(testing);"/> Kiosk 48</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="49" data-id="Kiosk 49" data-name="Kiosk 49" id="myCheckBox53" onchange="checkDisabled(testing);"/> Kiosk 49</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Melaka" data-name="Melaka" id="myCheckBox54" onchange="checkDisabled(testing);"/> Melaka</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="50" data-id="Kiosk 50" data-name="Kiosk 50" id="myCheckBox55" onchange="checkDisabled(testing);"/> Kiosk 50</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="51" data-id="Kiosk 51" data-name="Kiosk 51" id="myCheckBox56" onchange="checkDisabled(testing);"/> Kiosk 51</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="25" data-id="Kiosk 25" data-name="Kiosk 25" id="myCheckBox57" onchange="checkDisabled(testing);"/> Kiosk 25</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Perlis" data-name="Perlis" id="myCheckBox58" onchange="checkDisabled(testing);"/> Perlis</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="52" data-id="Kiosk 52" data-name="Kiosk 52" id="myCheckBox59" onchange="checkDisabled(testing);"/> Kiosk 52</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Negeri Sembilan" data-name="Negeri Sembilan" id="myCheckBox60" onchange="checkDisabled(testing);"/> Negeri Sembilan</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="53" data-id="Kiosk 53" data-name="Kiosk 53" id="myCheckBox61" onchange="checkDisabled(testing);"/> Kiosk 53</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="54" data-id="Kiosk 54" data-name="Kiosk 54" id="myCheckBox62" onchange="checkDisabled(testing);"/> Kiosk 54</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="65" data-id="Kiosk 65" data-name="Kiosk 65" id="myCheckBox63" onchange="checkDisabled(testing);"/> Kiosk 65</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Johor" data-name="Johor" id="myCheckBox64" onchange="checkDisabled(testing);"/> Johor</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="55" data-id="Kiosk 55" data-name="Kiosk 55" id="myCheckBox65" onchange="checkDisabled(testing);"/> Kiosk 55</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="56" data-id="Kiosk 56" data-name="Kiosk 56" id="myCheckBox66" onchange="checkDisabled(testing);"/> Kiosk 56</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="57" data-id="Kiosk 57" data-name="Kiosk 57" id="myCheckBox67" onchange="checkDisabled(testing);"/> Kiosk 57</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="58" data-id="Kiosk 58" data-name="Kiosk 58" id="myCheckBox68" onchange="checkDisabled(testing);"/> Kiosk 58</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="59" data-id="Kiosk 59" data-name="Kiosk 59" id="myCheckBox69" onchange="checkDisabled(testing);"/> Kiosk 59</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="60" data-id="Kiosk 60" data-name="Kiosk 60" id="myCheckBox70" onchange="checkDisabled(testing);"/> Kiosk 60</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="3" data-id="Kiosk 3" data-name="Kiosk 3" id="myCheckBox71" onchange="checkDisabled(testing);"/> Kiosk 3</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="4" data-id="Kiosk 4" data-name="Kiosk 4" id="myCheckBox72" onchange="checkDisabled(testing);"/> Kiosk 4</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="61" data-id="Kiosk 61" data-name="Kiosk 61" id="myCheckBox73" onchange="checkDisabled(testing);"/> Kiosk 61</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Kelantan" data-name="Kelantan" id="myCheckBox74" onchange="checkDisabled(testing);"/> Kelantan</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="62" data-id="Kiosk 62" data-name="Kiosk 62" id="myCheckBox75" onchange="checkDisabled(testing);"/> Kiosk 62</label></li>
</ul>
</li>
<hr/>
<li>
<label><input type="checkbox" data-id="Terengganu" data-name="Terengganu" id="myCheckBox76" onchange="checkDisabled(testing);"/> Terengganu</label>
<ul id="navlist">
<li><label><input type="checkbox" name="kioskMaster[]" value="63" data-id="Kiosk 63" data-name="Kiosk 63" id="myCheckBox77" onchange="checkDisabled(testing);"/> Kiosk 63</label></li>
<li><label><input type="checkbox" name="kioskMaster[]" value="64" data-id="Kiosk 64" data-name="Kiosk 64" id="myCheckBox78" onchange="checkDisabled(testing);"/> Kiosk 64</label></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
<div>
<p>Selected items (readable): <span class="selected-readable"></span></p>
<p>Selected items: <span class="selected">[]</span></p>
<p>Excepted items: <span class="excepted">[]</span></p>
</div>
<div class="checkbox">
<button id="testing" type="submit" class="btn btn-primary" disabled>Submit </button>
</div>
</form>