Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/476.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何获取数组中的复选框值_Javascript_Php_Checkbox - Fatal编程技术网

Javascript 如何获取数组中的复选框值

Javascript 如何获取数组中的复选框值,javascript,php,checkbox,Javascript,Php,Checkbox,如何从多个复选框中选中的值生成数组,并使用Ajax将其发送到另一个文件。 另外,当对任何以前选中的框执行取消选中时,如何从数组中删除选中的值。 请使用javascript帮助完成此操作。 下面是整个表单功能的安排。我也可以发送日期、月和年的值,但不能发送选定时间的值 <script> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, C

如何从多个复选框中选中的值生成数组,并使用Ajax将其发送到另一个文件。 另外,当对任何以前选中的框执行取消选中时,如何从数组中删除选中的值。 请使用javascript帮助完成此操作。 下面是整个表单功能的安排。我也可以发送日期、月和年的值,但不能发送选定时间的值

<script>
function loadXMLDoc()

{

    var xmlhttp;
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("containerG").innerHTML=xmlhttp.responseText;
    }
var date=document.getElementById("fdate).value;
var month=document.getElementById("fmonth").value;
var year=document.getElementById("fyear").value;
var year=document.getElementById("time").value;

var url ="selectedGraph.php?currentdate="+date"&currentmonth"+month"&currentyear="+year"&currenttime="+selectedtime;

alert("url");
}
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
</script>

函数loadXMLDoc()
{
var-xmlhttp;
if(window.XMLHttpRequest)
{//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}
其他的
{//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数()
{
if(xmlhttp.readyState==4&&xmlhttp.status==200)
{
document.getElementById(“containerG”).innerHTML=xmlhttp.responseText;
}
var date=document.getElementById(“fdate”).value;
var month=document.getElementById(“fmonth”).value;
var year=document.getElementById(“fyear”).value;
var year=document.getElementById(“时间”).value;
var url=“selectedGraph.php?currentdate=“+date”¤tmonth“+month”¤tyear=“+year”¤ttime=“+selectedtime;
警报(“url”);
}
open(“GET”,url,true);
xmlhttp.send();
}
下面是复选框函数-:

<?php function drop() { ?>

<div style="border:2px solid #ccc; width:130px; height: 100px; overflow-y: scroll;">
<input type="checkbox" name="multiple[]" value="01">1-2 Hours</input><br>
<input type="checkbox" name="multiple[]" value="02">2-3 Hours</input><br>
<input type="checkbox" name="multiple[]" value="03">3-4 Hours</input><br>
<input type="checkbox" name="multiple[]" value="04">4-5 Hours</input><br>
<input type="checkbox" name="multiple[]" value="05">5-6 Hours</input><br>
<input type="checkbox" name="multiple[]" value="06">6-7 Hours</input><br>
<input type="checkbox" name="multiple[]" value="07">7-8 Hours</input><br>
<input type="checkbox" name="multiple[]" value="08">8-9 Hours</input><br>
<input type="checkbox" name="multiple[]" value="09">9-10 Hours</input><br>
<input type="checkbox" name="multiple[]" value="10">10-11 Hours</input><br>
<input type="checkbox" name="multiple[]" value="11">11-12 Hours</input><br>
<input type="checkbox" name="multiple[]" value="12">12-13 Hours</input><br>
<input type="checkbox" name="multiple[]" value="13">13-14 Hours</input><br>
<input type="checkbox" name="multiple[]" value="14">14-15 Hours</input><br>
<input type="checkbox" name="multiple[]" value="15">15-16 Hours</input><br>
<input type="checkbox" name="multiple[]" value="16">16-17 Hours</input><br>
<input type="checkbox" name="multiple[]" value="17">17-18 Hours</input><br>
<input type="checkbox" name="multiple[]" value="18">18-19 Hours</input><br>
<input type="checkbox" name="multiple[]" value="19">19-20 Hours</input><br>
<input type="checkbox" name="multiple[]" value="20">20-21 Hours</input><br>
<input type="checkbox" name="multiple[]" value="21">21-22 Hours</input><br>
<input type="checkbox" name="multiple[]" value="22">22-23 Hours</input><br>
<input type="checkbox" name="multiple[]" value="23">23-24 Hours</input>
</div>
<?php }?>

<?php
echo "From: "; date_dropdown('from'); month_dropdown('from'); year_dropdown('from');      drop();?>

1-2小时
2-3小时
3-4小时
4-5小时
5-6小时
6-7小时
7-8小时
8-9小时
9-10小时
10-11小时
11-12小时
12-13小时
13-14小时
14-15小时
15-16小时
16-17小时
17-18小时
18-19小时
19-20小时
20-21小时
21-22小时
22-23小时
23-24小时
到目前为止你有什么?需要一些帮助吗?请帮助我。我会研究foreach循环,这可能是最好的。你会循环每个条目,并根据需要形成一个数组或字符串。如果看不到任何工作示例,很难确定你在哪里,你要去哪里,甚至是to建议替代方法。