2011-01-27 88 views
0

如何在php腳本中使用ajax調用發佈已選中複選框的值,即當用戶單擊複選框時,值將發佈到php腳本。使用ajax發佈複選框值

+0

先看看這篇文章,我想你可以適應你。 http://stackoverflow.com/questions/4816145/how-to-detect-that-a-user-has-unchecked-a-checkbox ---如果你只是需要在屏幕上打印其他東西,連接鏈接上面,將更改爲<?回聲'顯示的東西'; ?> ..我認爲會爲你工作。 – B4NZ41 2011-01-27 12:35:05

+0

jQuery是一個選項嗎? – 2011-01-27 12:36:27

回答

0

穿上覆選框onclick事件:

​​3210

,並作出這樣一個功能:

function postwithajax(e){ 
    //and here send with ajax e.checked 
} 
0

使用jQuery從HTML獲取值

$("#submit").click(function(){ 
    var myarray = []; 
    $("#div input:checked").each(function() { 
     myarray.push($(this).val()); //push each val into the array 
     }); 
     // here post Array with ajax 
    }); 

的Html

<html> 
<head> 
</head> 
<body> 
<div id="div"> 
    <input type="checkbox" value="one_name" checked> 
<input type="checkbox" value="one_name1"> 
<input type="checkbox" value="one_name2"> 
<input type="button" value="submit" id="submit"> 
</div> 
<textarea id="t"></textarea> 
</body> 
</html>