我想使用php中的AJAX方法更新状态。在php代码中,我添加了select命令以将状态更改为完成,并将值传递到update.php文件中。但没有改变发生AJAX Code:<script>function updatestatus(status) { if(str == '') { document.getElementById("res").innerHTML = ""; return; } 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 (this.readyState==4 && this.status==200) { document.getElementById("res").innerHTML=this.responseText; } } xmlhttp.open("GET","update.php?id=$row[id]"+str,true); xmlhttp.send();}PHP Code : I need to update the status from assigned to complete, plz help me in this regard.while ($row = mysqli_fetch_array($res)) { echo "<tr>"; echo "<td>".$row['project'];"</td>"; echo "<td>".$row['date'];"</td>"; echo "<td>".$row['tl_name'];"</td>"; echo "<td>".$row['subject'];"</td>"; echo "<td>".$row['details'];"</td>"; echo "<td> <form method='POST' action=''> <select name='status' id='status'> <option value='Assigned'>Assigned</option> <option value='Completed'>Completed</option> </select> </form> </td>"; echo "<td><input type='submit' id='button' name='button' onsubmit='updatestatus(this.value)' value='UPDATE'></td>"; echo "</tr>"; }In the update.php am using the below code: $status = $_POST['status']; $id = $_GET['id']; $sel = "update workassign set status ='$status' where id ='$id'"; $res = mysqli_query($conn,$sel);我需要将状态从已分配更新为完成,请在这方面帮助我。
1 回答
- 1 回答
- 0 关注
- 154 浏览
添加回答
举报
0/150
提交
取消