script:
$(function(){
$('#aa').change(function(){
var value=$(this).val();
$('#'+value).show().siblings().hide();
});
});
HTML:$(function(){
$('#aa').change(function(){
var value=$(this).val();
$('#'+value).show().siblings().hide();
});
});
HTML:$(function(){
$('select').change(function()
{
if($(this).val()=="其他"){
$("#other").show();
}else{
$("#other").hide();
}
});
});
設定change事件在切換select選單的時候就會去判斷$.ajax({ url: 'XXX.php', //url 用來指定要進行呼叫的位址
error: function(xhr) {//error 是定義當 Ajax 發生錯誤時會呼叫的 callback
alert('Ajax request 發生錯誤');
}, success: function(response) {//而 success 則是 Ajax 成功時呼叫的 callback。
$('#msg').html(response);//response直接就是 server 回應的內容)
function __construct()
{
parent::__construct();
$this->load->library('form_validation');
}
function checkadduser()//表單驗證
{
$config=array( //設定驗證規則
array(
'field'=>'account', //input的name
'label'=>'帳號', //設定名稱,在輸出錯誤訊息時出現的名稱
'rules'=>'trim|required|xss_clean' //驗證使用的規則
),
array(
'field'=>'password',
'label'=>'密碼',
'rules'=>'required|min_length[5]'
)
);
$this->form_validation->set_rules($config);
$this->form_validation->set_message('required','%s不能為空值'); //%s是帶入上面所設定的label
$this->form_validation->set_message('min_length','%s長度不能小於%s');
$this->form_validation->set_error_delimiters('','
'); //改變錯誤訊息的類別為error
if($this->form_validation->run() ==FALSE) //判斷是否符合格式
{
$this->adduserview(); //註冊失敗回到原頁面
}
else
{
$this->adduser();
}
}
接下來在view的顯示畫面加上錯誤訊息的顯示位置//錯誤訊息的程式碼
p.errorp {
color: #f00;
}
function index()
{
$this->page(0);//呼叫page函式並帶入0的數值
}
function page($set)
{
$this->load->library('pagination');
$data['title'] = "留言板"; //設定title
$data['heading'] = "留言板";//設定標題
$data['all'] = $this->db->count_all_results('book');
$config['base_url'] = base_url().'/book/page/';//設定頁面輸出網址
$config['total_rows'] = $this->db->count_all_results('book'); //計算所有筆數
$config['per_page'] = '10'; //一個分頁的數量
//以下是設定樣式
$config['full_tag_open'] = '';
$config['full_tag_close'] = '';
$config['first_link'] = '首頁';
$config['last_link'] = '末頁';
$config['next_link'] = '下一頁>';
$config['prev_link'] = '<上一頁';
$this->pagination->initialize($config);//初始化
$this->db->order_by('id','desc');
$this->db->limit($config['per_page'],$set);
$data['query']=$this->db->get('book');
$data['pagelist']=$this->pagination->create_links();//顯示分頁,如果沒有分頁不會印出
$this->load->view('book_viewend',$data);
}
date.timezone = Asia/Taipei
$b = 5;
$g = 1;
for($c=0;$c<5;$c++){
for($x=0;$x<$b;$x++)//印出空白
{
echo " ";
}
$b=$b-1;
for($y=0;$y<$g;$y++)//印出星號
{
echo "*";
}
$g=$g+2;
echo "
";
}
印出結果 *
***
*****
*******
*********
RewriteEngine on
RewriteCond $1 !^(index\.php)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
4. 修改 \application\config\cofig.php# -*- coding: UTF-8 -*-
'''
Python ver:3.1.3
Filename: usefile_1.py
Author: Rex Li
Data:2011-01-31
'''
print (__doc__)
p = '''\
這是一個文字檔建立的程式
試著去使用他吧
''' #斜線使第一行不空白
fileopen = open('ppp3.txt','w') #開啟檔案,w沒有該檔案就新增
fileopen.write(p) #寫入 p的內容
fileopen.close() #關閉檔案
fileopen = open('ppp3.txt')
while True:
line = fileopen.readline() #讀寫一行
if len(line) ==0: #檢視是否有字串
break
print (line)
fileopen.close()
Python ver:3.1.3 Filename: usefile_1.py Author: Rex Li Data:2011-01-31 這是一個文字檔建立的程式 試著去使用他吧簡易讀取
for i in open('ppp.txt'):
print (i)
# -*- coding: utf-8 -*-
# File name list.py
str = ['蘋果', '香蕉', '火龍果', '橘子']
print '我有', len(str),'樣東西在清單理'
for item in str:
print item,
print
print '我也需要買米'
str.append('米')
print '我的新的清單','[',
for item in str:
print item,
print ']'
print '排序我的清單','[',
for item in str:
print item,
print ']'
str.sort()
print '排序好的清單','[',
for item in str:
print item,
print ']'
print '我第一個要買的',str[0]
olditem = str[0]
del str[0]
print '我買了',olditem
print'我的現在清單','[',
for item in str:
print item,
print ']'
# -*- coding: utf8 -*-
'''
File name guess.py
REX li
2011-01-24
'''
number = 65
running = True
while running:#當running為 Ture 會執行下 程式
guess = int(raw_input('請輸入一個整數(0-100):'))
if guess == number:
print '恭喜!!你猜對了'
print '但沒有獎品= ='
running = False #如果為 False 會使程式終止
elif guess < number:
print '數字在大一點'
else:
print '數字在小一點'
else:
print '遊戲結束'
輸出結果
請輸入一個整數(0-100):55 數字在大一點 請輸入一個整數(0-100):66 數字在小一點 請輸入一個整數(0-100):65 恭喜!!你猜對了 但沒有獎品= = 遊戲結束參考網頁:http://code.google.com/p/zhpy/wiki/ControlFlow