如何用HTML5操作WebSQL数据库_第1页
已阅读5页,还剩7页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、如何用html5操作websql数据库html代码:列车时刻表查询列车时刻表查询请给我留言姓名:留言:留言查询保藏给我留言close保藏胜利,暂且不做处理!.请点击右上角有个关闭按钮提醒:你也可以点击弹窗的外部区域来关闭弹窗。js代码:/*html5操作本地websql数据库*作者:汪政*时光:2017/08/2615:03:19*/vardatatable=null;vardb=opendatabase("mydata","","mydatabase",1024*100);/初始化函数

2、办法functioninit()datatable=document.getelementbyid("datatable");showalldata();/首先移除污七八糟的东西functionremovealldata()for(vari=datatable.childnodes.length-1;i>=0;i-)datatable.removechild(datatable.childnodesi);vartr=document.createelement("tr");varth1=document.create

3、element("th");varth2=document.createelement("th");varth3=document.createelement("th");th1.innerhtml="姓名"th2.innerhtml="留言"th3.innerhtml="时光"tr.appendchild(th1);tr.appendchild(th2);tr.appendchi

4、ld(th3);datatable.appendchild(tr);/显示websql中的数据functionshowdata(row)vartr=document.createelement("tr");vartd1=document.createelement("td");td1.innerhtml=;vartd2=document.createelement("td");td2.innerhtml=row.message;vartd3=document.create

5、element("td");vart=newdate();t.settime(row.time);td3.innerhtml=t.tolocaledatestring()+""+t.tolocaletimestring();tr.appendchild(td1);tr.appendchild(td2);tr.appendchild(td3);datatable.appendchild(tr);/显示全部的数据functionshowalldata()db.transaction(function(tx)tx.execute

6、sql(&quot;createtableifnotexistsmsgdata(nametext,messagetext,timeinteger)&quot;,);tx.executesql(&quot;select*frommsgdata&quot;,function(tx,rs)removealldata();for(vari=0;i<rs.rows.length;i+)showdata(rs.rows.item(i)/添加数据functionadddata(name,message,time)db.transaction(function(tx)tx

7、.executesql(&quot;insertintomsgdatavalues(?,?,?)&quot;,name,message,time,function(tx,rs)alert(&quot;留言胜利!&quot;);,function(tx,error)alert(error.source+&quot;:&quot;+error.message);)/调用functionsavedata()varname=document.getelementbyid(&quot;name&quot;).value;varmemo=document.getelementbyid(&quot;memo&quot;).value;vartime=newdate().gettime();adddata(nam

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论