Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[simple guestbook] is implemented with the database added by HTML.

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

[simple guestbook] is implemented with the database added by HTML.

WEB message book implemented by database

Var datatable = null

Var db = openDatabase ('Mydata','','My Database',102400)

Function init () {

Datatable = document.getElementById ("datatable")

ShowAllData ()

}

Function removeAllData () {

For (var I = datatable.childNodes.length-1;i > = 0bot imuri -) {

Datatable.removeChild (datatable.childNodes [I])

}

Var tr = document.createElement ('tr')

Var th2 = document.createElement ('th')

Var th3 = document.createElement ('th')

Var th4 = document.createElement ('th')

Th2 [XSS _ clean] = "name"

TH3 [XSS _ clean] = "message"

TH4 [XSS _ clean] = "time"

Tr.appendChild (th2)

Tr.appendChild (th3)

Tr.appendChild (th4)

Datatable.appendChild (tr)

}

Function showData (row) {

Var tr = document.createElement ('tr')

Var td1 = document.createElement ('td')

TD1 [XSS _ clean] = row.name

Var td2 = document.createElement ('td')

TD2 [XSS _ clean] = row.message

Var td3 = document.createElement ('td')

Var t = new Date ()

T.setTime (row.time)

TD3 [XSS _ clean] = t.toLocaleDateString () + "+ t.toLocaleTimeString ()

Tr.appendChild (td1)

Tr.appendChild (td2)

Tr.appendChild (td3)

Datatable.appendChild (tr)

}

Function showAllData () {

Db.transaction (function (tx) {

Tx.executeSql ('CREATE TABLE IF NOT EXISTS MsgData (name TEXT,message TEXT,time INTEGER)', [])

Tx.executeSql ('SELECT * FROM MsgData', [], function (tx,rs) {

RemoveAllData ()

For (var I = 0; I

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report