<script>
var db;
var shortName = 'teste';
var version = '1.1';
var displayName = 'SQL_COM_JAVASCRITP';
var maxSize = 60000;
// CRIA CONEXÃO COM O BANCO
db = openDatabase(shortName, version, displayName, maxSize);
//CRIA BANCO tabela
//tx é o cursor
// transaction inicia a transação
db.transaction(function(tx){tx.executeSql('CREATE TABLE teste(id integer not null, nome text)')})
function insere(){
//--insere no banco de dados
        var id_ = document.getElementById("id").value;
        var nome_ = document.getElementById("nome").value;
		document.getElementById("inserido").value = "DADOS INSERIDOS...";
        //INSERE OS DADOS
        db.transaction(function(transaction) {
        transaction.executeSql('INSERT INTO teste(id, nome) VALUES (?,?)',[id_, nome_]);
});
}
function mostra_dados(){
// BUSCA OS DADOS tx é o cursor
        db.transaction(function(tx){tx.executeSql('SELECT * from teste', [], function(tx, resultado){
//MOSTRA OS DADOS --temos as linhas no resultado
        var rows = resultado.rows;
        for (var l = 0; l < rows.length; l++){
        //document.write( '<td>'+ rows[l].nome +'</td>'+'</br>');
        //document.write(rows[l].id);
		
        document.getElementById("resultado1").value = rows[l].nome;// VALUE PEGA O VALOR DO CAMPO
        document.getElementById("resultado2").value = rows[l].id;//value, ela refere-se ao valor do campo
		
} 
})});
}
function excluir(){
        var id_ = document.getElementById("id").value;
        db.transaction(function(transaction){transaction.executeSql('DELETE FROM teste WHERE id = ?', [id_,])
		
		});
        
}
function atualiza(){
        var id_ = document.getElementById("id").value;
        db.transaction(function(transaction){transaction.executeSql('UPDATE teste SET id = ?', [id_,])
		});
}
</script>