Created
November 11, 2012 21:27
-
-
Save knxroot/4056323 to your computer and use it in GitHub Desktop.
HTML5:websql ejemplo básico
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Web SQL</title> | |
<script type="text/javascript"> | |
function almacenar() | |
{ | |
var db=openDatabase('Mibbdd','1.0','mi base de datos', 2*1024*1024); | |
db.transaction(function(tx) | |
{ | |
tx.executeSql('CREATE TABLE IF NOT EXISTS tabla(nombre,apellido)'); | |
tx.executeSql('INSERT INTO tabla (nombre,apellido) VALUES ("Gustavo","Lacoste")'); | |
}); | |
alert("BBDD inicializada"); | |
db.transaction(function(tx) | |
{ | |
tx.executeSql('SELECT * FROM tabla',[],function(tx,results) | |
{ | |
var len=results.rows.length; | |
for (i=0;i<len;i++) | |
{ | |
alert(results.rows.item(i).nombre+" "+results.rows.item(i).apellido); | |
} | |
}); | |
}); | |
} | |
</script> | |
</head> | |
<body onload="almacenar();"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No existe la función: openDatabase()