如何从多个复选框中选中的值创建数组并使用 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"¤tmonth"+month"¤tyear="+year"¤ttime="+selectedtime;
alert("url");
}
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
</script>
下面是复选框功能-:
<?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();?>