前端学堂 http://www.felearn.com
当前位置首页 > 前端技术 > JavaScript> 正文

【javascript】如何删除页面某一个控件

2021-05-28 17:31:38 暂无评论 287 JavaScript 何用   javascript   删除

<html>
<head>
<script type = "text/javascript">
function onclick1()
{
aa.parentNode.removeChild(aa);
}
</script>

</head>
<body>
<input type="submit" onclick="onclick1();" value="click on this" />
<input type="text" id="aa" />
</body>
</html>

如何用javascript代码删除数据库里的数据?

IE 浏览器可以使用ActiveX adodb

function connection()
{

var i=2;
var dbname=name;
var url = "property.xml";
var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
xmldoc.load(url);
var property=xmldoc.getElementsByTagName("provider");
var dbpath=property[i].getElementsByTagName("dbpath")[0].firstChild.data;
var dbprovider=property[i].getElementsByTagName("dbprovider")[0].firstChild.data;
var dbuser=property[i].getElementsByTagName("dbuser")[0].firstChild.data;
var dbpassword=property[i].getElementsByTagName("dbpassword")[0].firstChild.data;
try{
var conn = new ActiveXObject("ADODB.Connection");
//var constr="Provider="+dbprovider+";Data Source="+dbpath+";User ID="+dbuser+";Jet OLEDB:Database Password="+dbpassword+";";
var constr="Provider="+dbprovider+";Data Source="+dbpath+";User ID="+dbuser+";Jet OLEDB:Database Password="+dbpassword+";";
conn.open(constr);
return conn;

}
catch(e){
alert("can not be connectting!");
conn.close;
return null;

}
finally{


}
}
function dbreadresult(strsql)
{
var strsql=strsql;
var i=0;
var result="";
try{
var conn=connection();
var rs = new ActiveXObject("ADODB.Recordset");
rs.open(strsql,conn,1,1);
var rowcount=rs.RecordCount;
var colcount=rs.Fields.Count;
while(!rs.eof)
{
result=result+rs.Fields(0);
for(j=1;j&lt;colcount;j++)

if(rs.Fields(j).Type==7){

dbdate=new Date(rs.Fields(j));

if((dbdate==null)||(dbdate=="null")||(dbdate &lt; new Date(2001,1,1))||(dbdate=="")){result=result+"\\t"+" ";}

else{result=result+"\\t"+datetostring(dbdate);}

}
else{

var dbdatastr=rs.Fields(j)+" ";

dbdatastr=dbdatastr.trim();

if((dbdatastr==null)||(dbdatastr=="null")||(dbdatastr=="")||(dbdatastr==" ")){result=result+"\\t"+" ";}

else{result=result+"\\t"+rs.Fields(j);}





}
result=result+"\
";
rs.moveNext();
}
return result;

}
catch(e){
alert(e.message);
return null;

}
finally{
rs.close;
conn.close;

}
}

猜你喜欢