Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 非独立升降箱_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript 非独立升降箱

Javascript 非独立升降箱,javascript,jquery,ajax,Javascript,Jquery,Ajax,我有以下代码: 函数addRow(tableID){ var table=document.getElementById(tableID); var rowCount=table.rows.length; var row=table.insertRow(rowCount); var colCount=table.rows[0].cells.length; 对于(变量i=0;i{ 开关(输入型){ 案例“文本”: inp.value=“”; 打破 案例“复选框”: inp.checked=fal

我有以下代码:

函数addRow(tableID){
var table=document.getElementById(tableID);
var rowCount=table.rows.length;
var row=table.insertRow(rowCount);
var colCount=table.rows[0].cells.length;
对于(变量i=0;i

选择一个主题
1.
2.
3.
选择一个主题。。。
aaa

开始测验
我想你是想这么做的

我无法测试Ajax,但请取消注释并重试

函数addRow(tableID){
var table=document.getElementById(tableID);
var rowCount=table.rows.length;
var newRow=table.rows[0].cloneNode(true);
newRow.querySelector(“.txtHint”).innerHTML=“选择主题”;
[…newRow.querySelectorAll(“输入,选择”)].forEach(inp=>{
开关(输入型){
案例“文本”:
inp.value=“”;
打破
案例“复选框”:
inp.checked=false;
打破
案例“选择一个”:
inp.id=“sel”+行数;
inp.selectedIndex=0;
打破
}
})
表2.appendChild(纽罗);
}
功能显示用户(sel){
var str=选择值,
id=sel.id,
sel=document.getElementById(id);
如果(str==“”){
var rowCount=table.rows.length;
sel.closest(“tr”).querySelector(“textHint”).innerHTML=“”;
返回;
}否则{
console.log(id,str)
/*
if(window.XMLHttpRequest){
//IE7+、Firefox、Chrome、Opera、Safari的代码
xmlhttp=新的XMLHttpRequest();
}否则{
//IE6、IE5的代码
xmlhttp=新的ActiveXObject(“Microsoft.xmlhttp”);
}
xmlhttp.onreadystatechange=函数(){
if(this.readyState==4&&this.status==200){
document.getElementById(id).closest(“tr”).querySelector(“textHint”).innerHTML=this.responseText;
}
};
open(“GET”、“getcategory.php?q=“+str,true”);
xmlhttp.send();
*/
}
}

选择一个主题
1.
2.
3.
选择一个主题。。。
aaa

开始测验
这显然不是一个PHP问题,请仅使用HTML和脚本重新标记并创建一个id-您的问题是重复id,它们需要唯一,因为id是相同的,这就是为什么在数据更新时总是考虑第一行。使用
class
attribute你能告诉我怎么做吗?哇,它真的起作用了。非常感谢。单击创建新行时,是否有方法重置div?因为现在它保留了以前的数据,然后在新数据中选择任何内容。