//createElement()创建input元素到obj对象中
var obj = document.createElement('input')
//选择要生成地点的前一个元素
var before = document.getElementById('before')
//设置obj元素名,值
obj.name='name'
obj.value='value'
//setAttribute是可以自由定义属性的,不仅id和type,name和value也可以在这定义
obj.setAttribute('id','idname')
obj.setAttribute('type','typename')
//在前一个元素后面添加obj
before.appendChild(obj)
方法二:
document.write("<inpt name='name' value='value' id='idname' type='typename'>")
理论上不建议这样连,但是也可以连的
代码如下:
<script type="text/javascript" language="javascript" charset="gb2312"><!--
function getCountFromDB() {
var filePath = location.href.substring(0, location.href.indexOf("index.html"))
var path = filePath + "MyData.mdb"
path = path.substring(8)
var updateCnt = 0
var sqlSelCnt = "SELECT * FROM [user]"
var con = new ActiveXObject("ADODB.Connection")
con.Provider = "Microsoft.Jet.OLEDB.4.0"
con.ConnectionString = "Data Source=" + path
con.open
var rs = new ActiveXObject("ADODB.Recordset")
rs.open (sqlSelCnt,con)
while (!rs.eof) {
var cnt = rs.Fields("content")
document.write (cnt)
rs.moveNext
}
rs.close()
rs = null
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)