1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Websql applications</title>6 <Scriptsrc= "Http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"type= "Text/javascript"></Script>7 </Head>8 <Body>9 <inputtype= "text"ID= "title" />Ten <textareaname= "Context"ID= "Context"cols= " the"rows= "8"></textarea> One <inputtype= "button"value= "Save"onclick= "Save ()" /> A <inputtype= "button"value= "View"onclick= "Chakan ()" /> - <olID= "Chakan"> - 123 the </ol> - </Body> - <Script> - vardbsize=2*1024x768*1024x768; + DB=OpenDatabase ("Todo","","", dbsize); - Db.transaction (function(TX) { + Tx.executesql ("CREATE TABLE IF not EXISTS notes (ID integer PRIMARY key,title char (), Inputmemo text,last_date datetime)"); A } at ); - functionSave () { - vartitle=$("#title"). Val (); - varInputmemo=$("#context"). Val (); - Db.transaction (function(TX) { - Tx.executesql ("INSERT into notes (title,inputmemo,last_date) VALUES (?,?, datetime (' Now ', ' localtime ')", [Title,inputmemo]); in }); - } to functionChakan () { + $("ol"). empty (); - varNote=""; the Db.transaction (function(TX) { * Tx.executesql ("SELECT id,title,inputmemo,last_date from Notes",[],function(tx,result) { $ if(Result.rows.length>0){Panax Notoginseng for (varI= 0; I<result.rows.length; I++) { - varItem=Result.rows.item (i); the //Console.log (item["Inputmemo"]); + Note+="<li>"+""+item["title"]+""+item["Inputmemo"]+"</p></li>"; A } the $("#chakan"). append (note); + }} - ); $ }); $ } - </Script> - </HTML>
Websql Use Instances