我想插入複選框的值沒有提交按鈕,但我無法獲得我的複選框值在我的jquery代碼請讓我在這個問題,我必須使用jquery函數讓我值我新新腳本javascript函數複選框的值沒有提交按鈕在PHP
<?php
date_default_timezone_set('Asia/Kolkata');
$a=date('H');
$b=8;$c=15;
if($b<$a&&$a<=$c)
{
$status='check="unchecked"';
}
else
{
$status = 'disabled="disabled"';
}
?>
<form >
<div align="center">
<table>
<tr>
<td>
<p>S.NO</p>
</td>
<td>
<p>Check Box</p>
</td>
<td>
<p>Activity Name</p>
</td>
</tr>
<tr>
<td>
1
</td>
<td>
<input type="checkbox" class="get_value" value="Bod1" <?php echo $status ?> />
</td>
<td>
<label for="Bod1">BOD1 </label>
</td>
</tr>
<tr>
<td>
2
</td>
<td>
<input type="checkbox" class="get_value"value="Bod2"<?php echo $status ?> />
</td>
<td>
<label for="Bod2">BOD2 </label>
</td>
</tr>
<tr>
<td>
3
</td>
<td>
<input type="checkbox" class="get_value" value="Bod3"<?php echo $status ?>/>
</td>
<td>
<label for="Bod3">BOD3</label>
</td>
</tr>
<tr>
<td>
4
</td>
<td>
<input type="checkbox" class="get_value" value="Bod4" <?php echo $status ?>/>
</td>
<td>
<label for="Bod4">BOD4 </label>
</td>
</tr>
<tr>
<td>
5
</td>
<td>
<input type="checkbox" class="get_value" value="Bod5" <?php echo $status ?> />
</td>
<td>
<label for="Bod5">BOD5 </label>
</td>
</tr>
</div>
</div>
</form>
<script>
$(document).ready(function() {
var languages=[];
//$.each($("input[name='checklist[]']:checked"), function(){
/alert($(this).val());
// $("input[name='checklist[]']").each(function() {
var checkedvalue=$('.check_list:checked').val();
var checkedvalue=null;
var inputelements=document.getelementbyclassname('check_list');
for(var i=0;inputelements[i];i++){
if(inputelements[i].checked){
checkedvalue=inputelements[i].value;
});
checkedvalue=checkedvalue.toString();
$.ajax({
url:"dummyeodcheckbox.php";
type:"post"
data:{languages:languages};
success:function(data){
var result=result.data;
alert("function called successfully");
}
});
});
});
</script>
爲什麼你有兩個名爲checkedvalue的變量? 'var checkedvalue = $('。check_list:checked')。val();' 'var checkedvalue = null;' – Treesa