Get the App
SLTechnology News&Howtos  ›  Database  › 

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

Shulou Source: shulou.com Published: 2022-06-01 12:03:53 10月02日 Update

[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

Tags: Data database guestbook name success time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Shulou Information Xiaomi MySQL macOS