<!DOCTYPE html>
<html>
<head>
<meta charset="BIG5">
<title>Insert title here</title>
<script type="text/javascript" src="json.js"></script>
<script>
var people =
{ "programmers": [
{ "firstName": "Brett", "lastName":"McLaughlin", "email": "brett@newInstance.com" },
{ "firstName": "Jason", "lastName":"Hunter", "email": "jason@servlets.com" },
{ "firstName": "Elliotte", "lastName":"Harold", "email": "elharo@macfaq.com" }
],
"authors": [
{ "firstName": "Isaac", "lastName": "Asimov", "genre": "science fiction" },
{ "firstName": "Tad", "lastName": "Williams", "genre": "fantasy" },
{ "firstName": "Frank", "lastName": "Peretti", "genre": "christian fiction" }
],
"musicians": [
{ "firstName": "Eric", "lastName": "Clapton", "instrument": "guitar" },
{ "firstName": "Sergei", "lastName": "Rachmaninoff", "instrument": "piano" }
]
};
alert(people.programmers[0].firstName);
var stuents=new Object();
stuents.name="egg";
stuents.scope=100;
alert(stuents.toJSONString());
</script>
</head>
<body>
</body>
</html>
2013年9月29日 星期日
2013年9月27日 星期五
login流程設計&分析
1.login的機制要完成
登入成功:帳號要存在變數,將isLogined=true
登入失敗:免做
2.是否要記住帳號 :
沒勾==>>勾選-->立即檢查islogined -->true:立即存帳號
-->false:沒事,等登入鈕按下-->再存
勾選 ==>>沒勾:show對話框-->NO:沒事
-->YES:delete file(或刪內容)
3.離開程式,再執行:檢查,A.有無勾選狀態要儲存B.若有勾選,id.setText("先前帳號'),否則沒事。
登入成功:帳號要存在變數,將isLogined=true
登入失敗:免做
2.是否要記住帳號 :
沒勾==>>勾選-->立即檢查islogined -->true:立即存帳號
-->false:沒事,等登入鈕按下-->再存
勾選 ==>>沒勾:show對話框-->NO:沒事
-->YES:delete file(或刪內容)
3.離開程式,再執行:檢查,A.有無勾選狀態要儲存B.若有勾選,id.setText("先前帳號'),否則沒事。
補充JAVA檔案API
JAVA檔案API
1.分兩大類:
A.檔案管理:
向name、size、datetime、attribute、delete
B.檔案讀寫:
以甚麼單位讀寫 、採覆蓋()或銜接模式
2.重點:
A.不論FILE或FOLDER皆已File類別宣告
B.宣告File不代表已建立folder、file
C.建folder,須以mkdirs()或mkdir()。
建file,須以createNewFile()。
D.File建構子可填絕對路徑(EX:C:\books)
或相對路徑 (EX:.\books【本身一層】 或..\books【上一層】)
E.常用API有exists()、isDirectory()、getName()、isFile、remaneTo()、list()、lastModified()、length()。
1.分兩大類:
A.檔案管理:
向name、size、datetime、attribute、delete
B.檔案讀寫:
以甚麼單位讀寫 、採覆蓋()或銜接模式
2.重點:
A.不論FILE或FOLDER皆已File類別宣告
B.宣告File不代表已建立folder、file
C.建folder,須以mkdirs()或mkdir()。
建file,須以createNewFile()。
D.File建構子可填絕對路徑(EX:C:\books)
或相對路徑 (EX:.\books【本身一層】 或..\books【上一層】)
E.常用API有exists()、isDirectory()、getName()、isFile、remaneTo()、list()、lastModified()、length()。
監聽器的三種基本用法
1.以所在的類別實作監聽器
2.宣告一個【具名類別】並加以實體化(紅色字體)
3.宣告一個【匿名類別】並加以實體化
package com.example.onclick_1;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class OnClick extends Activity {
int count =0;
Button bt1;
// 2. 實作 OnClick 監聽器 step #1
// class MyOnClickListener implements OnClickListener {
//
// @Override
// public void onClick(View v) {
// // TODO Auto-generated method stub
// count++;
// setTitle(count+"");
// }
// }
// MyOnClickListener listener = new MyOnClickListener();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_on_click);
bt1 = (Button) findViewById(R.id.button1);
// 1. 註冊 OnClick 監聽器
// bt1.setOnClickListener(this);
// bt1.setOnClickListener(listener);
bt1.setOnClickListener( new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
count++;
setTitle(count+"");
}} );
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.on_click, menu);
return true;
}
// 2. 實作 OnClick 監聽器 step #2
// @Override
// public void onClick(View v) {
// // TODO Auto-generated method stub
// count++;
// setTitle(count+"");
// }
}
2.宣告一個【具名類別】並加以實體化(紅色字體)
3.宣告一個【匿名類別】並加以實體化
package com.example.onclick_1;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class OnClick extends Activity {
int count =0;
Button bt1;
// 2. 實作 OnClick 監聽器 step #1
// class MyOnClickListener implements OnClickListener {
//
// @Override
// public void onClick(View v) {
// // TODO Auto-generated method stub
// count++;
// setTitle(count+"");
// }
// }
// MyOnClickListener listener = new MyOnClickListener();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_on_click);
bt1 = (Button) findViewById(R.id.button1);
// 1. 註冊 OnClick 監聽器
// bt1.setOnClickListener(this);
// bt1.setOnClickListener(listener);
bt1.setOnClickListener( new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
count++;
setTitle(count+"");
}} );
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.on_click, menu);
return true;
}
// 2. 實作 OnClick 監聽器 step #2
// @Override
// public void onClick(View v) {
// // TODO Auto-generated method stub
// count++;
// setTitle(count+"");
// }
}
2013年9月25日 星期三
上課筆記-findViewByID( *** )重點
1.此為ANDROID指令,為在JAVA和調色板之間做溝通。
2.***為ID參數,用法為R.id.[]
R:在gen/R.java,此為自動產生的檔案,勿修改。
.id為R的內部靜態類別。
[]為調色板內所定義的id代號。
3.用法:et1=(EditText) findViewById(R.id.editText1);
(EditText) =>多形的應用,可轉成對應的子類別。
findViewById=>原本傳回父類別View。
2.***為ID參數,用法為R.id.[]
R:在gen/R.java,此為自動產生的檔案,勿修改。
.id為R的內部靜態類別。
[]為調色板內所定義的id代號。
3.用法:et1=(EditText) findViewById(R.id.editText1);
(EditText) =>多形的應用,可轉成對應的子類別。
findViewById=>原本傳回父類別View。
DOM的寫法-
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<jsp:useBean id="mylist" scope="page" class="com.shaojung.shopping.CategoryDAO" />
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
pageContext.setAttribute("catlist", mylist.getlistbyMainID(0));
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script language="javascript" type="text/javascript">
var request = new XMLHttpRequest();
function funclick()
{
var id = document.getElementById("MainID").value;
request.open("GET", "GetSubCategory.jsp?ID=" + id, false);
request.onreadystatechange = updatePage;
request.send(null);
}
function updatePage() {
if (request.readyState == 4)
if (request.status == 200)
{
var ops = request.responseText.split('|');
var selectbox=document.getElementById("SubID");
for (var j=ops.length-1;j>=0;j--)
{
selectbox.remove(j);
}
for (var i=0;i<ops.length;i++)
{
var new_option = new Option(ops[i], i);
selectbox.options.add(new_option);
}
}
// document.getElementById("show").innerHTML = request.responseText;
}
</script>
</head>
<body>
<p>
<label for="MainID">分類</label>
<select name="MainID" id="MainID" onchange="funclick()">
<c:forEach items="${catlist}" var="item">
<option value="${item.ID}">${item.CName}</option>
</c:forEach>
</select>
</p>
<p><span id="show"></span></p>
<label for="SubID">子分類</label>
<select name="SubID" id="SubID">
</select>
</body>
</html>
pageEncoding="utf-8"%>
<jsp:useBean id="mylist" scope="page" class="com.shaojung.shopping.CategoryDAO" />
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
pageContext.setAttribute("catlist", mylist.getlistbyMainID(0));
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script language="javascript" type="text/javascript">
var request = new XMLHttpRequest();
function funclick()
{
var id = document.getElementById("MainID").value;
request.open("GET", "GetSubCategory.jsp?ID=" + id, false);
request.onreadystatechange = updatePage;
request.send(null);
}
function updatePage() {
if (request.readyState == 4)
if (request.status == 200)
{
var ops = request.responseText.split('|');
var selectbox=document.getElementById("SubID");
for (var j=ops.length-1;j>=0;j--)
{
selectbox.remove(j);
}
for (var i=0;i<ops.length;i++)
{
var new_option = new Option(ops[i], i);
selectbox.options.add(new_option);
}
}
// document.getElementById("show").innerHTML = request.responseText;
}
</script>
</head>
<body>
<p>
<label for="MainID">分類</label>
<select name="MainID" id="MainID" onchange="funclick()">
<c:forEach items="${catlist}" var="item">
<option value="${item.ID}">${item.CName}</option>
</c:forEach>
</select>
</p>
<p><span id="show"></span></p>
<label for="SubID">子分類</label>
<select name="SubID" id="SubID">
</select>
</body>
</html>
2013年9月23日 星期一
sql-convert語法
SELECT 訂單.訂單序號,convert(char,訂單.日期,111),客戶.客戶名稱 from 訂單 inner join 客戶 on 訂單.客戶編號=客戶.客戶編號
convert有三個引數,
convert有三個引數,
CONVERT ( data_type [ ( length ) ] , expression [ , style ] )
style是用數字代表,可用google用msql convert關鍵字查詢:
11 = yy/mm/dd
111 = yyyy/mm/dd
訂閱:
文章 (Atom)