Archive for the ‘HTML’ Category

Store SQLite database on HTML5

Posted: May 19, 2012 in HTML

Store SQLite database on HTML5

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>SQL Storage</title>
<body>
<br/><br/>
<div align=”center”>
<input type=”hidden” id=”id”/>
First name:<input type=”text” id=”firstName”/><br/>
Last name:<input type=”text” id=”lastName”/><br/>
Phone: <input type=”text” id=”phone”/><br/>
<button onClick=”resetForm()”>Reset Form</button>
<button onClick=”updateRecord()”>Update</button>
<button onClick=”insertRecord()”>Insert</button>
<button onClick=”dropTable()”>Drop Table</button>
<div id=”results”></div>
</div>
</body>
(more…)

To sending params such as index.html?param1=xx&param2=yy, we can use window.location.search.

Example:

var params = window.location.search.slice(1).split(“&”);
for(var p=0; p<params.length; p++) {
var pair = params[p].split("=");
var name = pair[0] ;
var value = pair[1];
// What you want to do with name and value…
if( name == 'param1' ){
//
}else if(name == 'param2'){
//
}
}