该函数显示数据库中文件的类型的一系列信息,并以表格形式显示该文件,并在每行旁边显示2个更改字段值的按钮。
相反,功能使能应该以按钮的id作为输入,知道按钮的id后,我将输入传递给php页面的行中的值作为接受值进行更新。但是恰恰是启用功能无法正常工作,因为它应该阻止所有内容。
<SCRIPT>
var i=0;
function showTipo(str){
$("#demo").remove();
var obj, dbParam, xmlhttp, myObj, x,t,txt = "";
//var i=0;
var a= new Array();
// obj = { "table":sel, "limit":20 };
// dbParam = JSON.stringify(obj);
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if (this.readyState == 4 && this.status == 200) {
$("#secondo").before("<center><div id='demo' class='w3-row-padding w3-padding-64 w3-container'> </div></center>");
myObj = JSON.parse(this.responseText);
$("#demo").prepend("<div> <table border='1' width='75%'> <tr><th width='25%'>Tipologia</th><th width='25%'>Abilitata</th><th width='25%'>Azioni</th></tr></table><table border='1' id='tab' width='75%'></div> ");
/* if(myObj[x].tipologia_abilitata== "2"){}
else{}
*/
for (x in myObj) {
i=i+1;
if(myObj[x].tipologia_abilitata != "2"){
// txt +="<tr><td width='25%'>" + myObj[x].tipologia + "</td> <td width='25%'> <div id='vero' class='w3-container'>"+myObj[x].tipologia_abilitata + "</div></td></tr> ";
//document.getElementById("tab").innerHTML = "<tr><td width='25%'>" + myObj[x].tipologia + "</td> <td width='35%'> <div id='vero' class='w3-container'>"+myObj[x].tipologia_abilitata + "</div></td></tr> ";
if(myObj[x].tipologia_abilitata == "1")
{
myObj[x].tipologia_abilitata = "ABILITATO";
}
else
{
myObj[x].tipologia_abilitata = "DISABILITATO ";
}
txt +="<tr><td width='25%' id='cln'"+ i+">" + myObj[x].tipologia + "</td> <td width='25%'> "+myObj[x].tipologia_abilitata + "</td> <td width='25%'> <button id='abil'"+i +" class='w3-button' onClick=Abilita(this.id,i)>Abilita</button> <button id='dis'"+i+ " class='w3-button' onclick=Abilita('./Abilta.php','myObj[x]')'>Disabilità</button></td></tr> ";
}}
txt += "</table>"
document.getElementById("tab").innerHTML = txt;
}
$("#tab").after= " <br> <br><button class:'w3-button'> Aggiungi Tipologia </button> <button>Modifica</button>";
};
xmlhttp.open("POST", "VisualizzaCategorie.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("Nome_ente=" + str);
}
//cambio da disabilita ad abilita
/*function Abilita(id,indice){
var str;
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
var trovato=false;
var i=0;
while(i<=indice || trovato ==false){
if(id == "abil"+i){
str= document.getElementById("cln"+i).value
trovato=true
}
i=i+1;
}
}
};
xmlhttp.open("POST", "Abilita.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("tipo=" + str);
}*/
</SCRIPT>
我就是不明白为什么。
可以帮我提供帮助代码吗?还是功能完全错误,是否可以做我想做的事情?