#FFF2F2 | #FFE8E8 | #FFDEDE | #FFD4D4 | #FFC9C9 | #FFBFBF | #FFB5B5 | #FFABAB |
#FFA1A1 | #FF9696 | #FF8C8C | #FF8282 | #FF7878 | #FF6E6E | #FF6363 | #FF5959 |
#FF5F5F | #FF4545 | #FF3B3B | #FF3030 | #FF2626 | #FF1C1C | #FF1212 | #FF0000 |
#F50000 | #F00000 | #EB0000 | #E60000 | #E00000 | #DB0000 | #D60000 | #D10000 |
#CC0000 | #C70000 | #C20000 | #BD0000 | #B80000 | #B20000 | #AD0000 | #A80000 |
#A30000 | #9E0000 | #990000 | #940000 | #8F0000 | #8A0000 | #850000 | #800000 |
#FFFAF2 | #FFF7E8 | #FFF3DE | #FFF0D4 | #FFECC9 | #FFE8BF | #FFE5B5 | #FFE1AB |
#FFDEA1 | #FFDA96 | #FFD78C | #FFD382 | #FFCF78 | #FFCC6E | #FFC863 | #FFC559 |
#FFC14F | #FFBD45 | #FFBA3B | #FFB630 | #FFB326 | #FFB01C | #FFAC12 | #FFA600 |
#F59F00 | #F09C00 | #EB9900 | #E69500 | #E09200 | #DB8F00 | #D68B00 | #D18800 |
#CC8500 | #C78100 | #C27E00 | #BD7B00 | #B87800 | #B27400 | #AD7100 | #A86E00 |
#A36A00 | #9E6700 | #996400 | #946000 | #8F5D00 | #8A5A00 | #855600 | #805300 |
#FFFFF2 | #FFFFE8 | #FFFFDE | #FFFFD4 | #FFFFC9 | #FFFFBF | #FFFFB5 | #FFFFAB |
#FFFFA1 | #FFFF96 | #FFFF8C | #FFFF82 | #FFFF78 | #FFFF6E | #FFFF63 | #FFFF59 |
#FFFF4F | #FFFF45 | #FFFF3B | #FFFF30 | #FFFF26 | #FFFF1C | #FFFF0F | #FFFF00 |
#F5F500 | #F0F000 | #EBEB00 | #E6E600 | #E0E000 | #DBDB00 | #D6D600 | #D1D100 |
#CCCC00 | #C7C700 | #C2C200 | #BDBD00 | #B8B800 | #B2B200 | #ADAD00 | #A8A800 |
#A3A300 | #9E9E00 | #999900 | #949400 | #8F8F00 | #8A8A00 | #858500 | #808000 |
#F2FFF2 | #E8FFE8 | #DEFFDE | #D4FFD4 | #C9FFC9 | #BFFFBF | #B5FFB5 | #ABFFAB |
#A1FFA1 | #96FF96 | #8CFF8C | #82FF82 | #78FF78 | #6EFF6E | #63FF63 | #59FF59 |
#4FFF4F | #45FF45 | #3BFF3B | #30FF30 | #26FF26 | #1AFF19 | #0DFF0D | #00FF00 |
#00F500 | #00F000 | #00EB00 | #00E600 | #00E000 | #00DB00 | #00D600 | #00D100 |
#00CC00 | #00C700 | #00C200 | #00BD00 | #00B800 | #00B200 | #00AD00 | #00A800 |
#00A300 | #009E00 | #009900 | #009400 | #008F00 | #008A00 | #008500 | #008000 |
#F2FFFF | #E8FFFF | #DEFFFF | #D4FFFF | #C9FFFF | #BFFFFF | #B5FFFF | #ABFFFF |
#A1FFFF | #96FFFF | #8CFFFF | #82FFFF | #78FFFF | #6EFFFF | #63FFFF | #59FFFF |
#4FFFFF | #45FFFF | #3DFFFF | #30FFFF | #26FFFF | #1CFFFF | #12FFFF | #00FFFF |
#00F5F5 | #00F0F0 | #00EBEB | #00E6E6 | #00E0E0 | #00DBDB | #00D6D6 | #00D1D1 |
#00CCCC | #00C7C7 | #00C2C2 | #00BDBD | #00B8B8 | #00B2B2 | #00ADAD | #00A8A8 |
#00A3A3 | #009E9E | #009999 | #009494 | #008F8F | #008A8A | #008585 | #008080 |
#EBEBFF | #E0E0FF | #D6D6FF | #CCCCFF | #C2C2FF | #B8B8FF | #ADADFF | #A3A3FF |
#9999FF | #8C8CFF | #8282FF | #7878FF | #6E6EFF | #6363FF | #5959FF | #4F4FFF |
#4545FF | #3B3BFF | #3030FF | #2626FF | #1C1CFF | #1212FF | #0808FF | #0000FF |
#0000FA | #0000F5 | #0000EB | #0000E6 | #0000E0 | #0000DB | #0000D6 | #0000D1 |
#0000CC | #0000C7 | #0000C2 | #0000BD | #0000B8 | #0000B2 | #0000AD | #0000A8 |
#0000A3 | #00009E | #000099 | #000094 | #00008F | #00008A | #000085 | #000080 |
#FAF2FF | #F5E8FF | #F1DEFF | #EDD4FF | #E8C9FF | #E4BFFF | #E0B5FF | #DBABFF |
#D7A1FF | #D396FF | #CE8CFF | #CA82FF | #C678FF | #C26EFF | #BD63FF | #B959FF |
#B54FFF | #B045FF | #AC3BFF | #A830FF | #A326FF | #9F1CFF | #990DFF | #9300FF |
#9300FF | #8D00F5 | #8700EB | #8400E6 | #8100E0 | #7F00DB | #7C00D6 | #7900D1 |
#7600CC | #7300C7 | #7000C2 | #6D00BD | #6A00B8 | #6700B2 | #6400AD | #6100A8 |
#5E00A3 | #5B009E | #580099 | #550094 | #52008F | #4F008A | #4C0085 | #4A0080 |
#FFF2FF | #FFE8FF | #FFDEFF | #FFD4FF | #FFC9FF | #FFBFFF | #FFB5FF | #FFABFF |
#FFA1FF | #FF96FF | #FF8CFF | #FF82FF | #FF78FF | #FF6EFF | #FF63FF | #FF59FF |
#FF4FFF | #FF45FF | #FF3BFF | #FF30FF | #FF26FF | #FF19FF | #FF0DFF | #FF00FF |
#F700F7 | #F000F0 | #EB00EB | #E600E5 | #E000E0 | #DB00DB | #D600D6 | #D100D1 |
#CC00CC | #C700C7 | #C200C2 | #BD00BD | #B800B8 | #B200B2 | #AD00AD | #A800A8 |
#A300A3 | #9E009E | #990099 | #940094 | #8F008F | #8A008A | #850085 | #800080 |
#FAFAFA | #F5F5F5 | #EDEDED | #E8E8E8 | #E3E3E3 | #DEDEDE | #D9D9D9 | #D4D4D4 |
#CFCFCF | #C9C9C9 | #C4C4C4 | #BFBFBF | #BABABA | #B5B5B5 | #B0B0B0 | #ABABAB |
#A6A6A6 | #A1A1A1 | #9C9C9C | #969696 | #919191 | #8C8C8C | #878787 | #828282 |
#7D7D7D | #787878 | #737373 | #6E6E6E | #696969 | #636363 | #5E5E5E | #595959 |
#545454 | #4F4F4F | #4A4A4A | #454545 | #404040 | #3B3B3B | #363636 | #303030 |
#2B2B2B | #262626 | #212121 | #1C1C1C | #171717 | #0F0F0F | #0A0A0A | #000000 |
2017年9月29日 星期五
漸層色碼表
https://www.w3schools.com/colors/ 有更多的工具和內容
漸層調色盤
#000000 | #2F0000 | #600030 | #460046 | #28004D | |||||
#272727 | #4D0000 | #820041 | #5E005E | #3A006F | |||||
#3C3C3C | #600000 | #9F0050 | #750075 | #4B0091 | |||||
#4F4F4F | #750000 | #BF0060 | #930093 | #5B00AE | |||||
#5B5B5B | #930000 | #D9006C | #AE00AE | #6F00D2 | |||||
#6C6C6C | #AE0000 | #F00078 | #D200D2 | #8600FF | |||||
#7B7B7B | #CE0000 | #FF0080 | #E800E8 | #921AFF | |||||
#8E8E8E | #EA0000 | #FF359A | #FF00FF | #9F35FF | |||||
#9D9D9D | #FF0000 | #FF60AF | #FF44FF | #B15BFF | |||||
#ADADAD | #FF2D2D | #FF79BC | #FF77FF | #BE77FF | |||||
#BEBEBE | #FF5151 | #FF95CA | #FF8EFF | #CA8EFF | |||||
#d0d0d0 | #ff7575 | #ffaad5 | #ffa6ff | #d3a4ff | |||||
#E0E0E0 | #FF9797 | #FFC1E0 | #FFBFFF | #DCB5FF | |||||
#F0F0F0 | #FFB5B5 | #FFD9EC | #FFD0FF | #E6CAFF | |||||
#FCFCFC | #FFD2D2 | #FFECF5 | #FFE6FF | #F1E1FF | |||||
#FFFFFF | #FFECEC | #FFF7FB | #FFF7FF | #FAF4FF | |||||
#000079 | #000079 | #003E3E | #006030 | #006000 | |||||
#000093 | #003D79 | #005757 | #01814A | #007500 | |||||
#0000C6 | #004B97 | #007979 | #019858 | #009100 | |||||
#0000C6 | #005AB5 | #009393 | #01B468 | #00A600 | |||||
#0000E3 | #0066CC | #00AEAE | #02C874 | #00BB00 | |||||
#2828FF | #0072E3 | #00CACA | #02DF82 | #00DB00 | |||||
#4A4AFF | #0080FF | #00E3E3 | #02F78E | #00EC00 | |||||
#6A6AFF | #2894FF | #00FFFF | #1AFD9C | #28FF28 | |||||
#7D7DFF | #46A3FF | #4DFFFF | #4EFEB3 | #53FF53 | |||||
#9393FF | #66B3FF | #80FFFF | #7AFEC6 | #79FF79 | |||||
#AAAAFF | #84C1FF | #A6FFFF | #96FED1 | #93FF93 | |||||
#B9B9FF | #97CBFF | #BBFFFF | #ADFEDC | #A6FFA6 | |||||
#CECEFF | #ACD6FF | #CAFFFF | #C1FFE4 | #BBFFBB | |||||
#DDDDFF | #C4E1FF | #D9FFFF | #D7FFEE | #CEFFCE | |||||
#ECECFF | #D2E9FF | #ECFFFF | #E8FFF5 | #DFFFDF | |||||
#FBFBFF | #ECF5FF | #FDFFFF | #FBFFFD | #F0FFF0 | |||||
#467500 | #424200 | #5B4B00 | #844200 | #642100 | |||||
#548C00 | #5B5B00 | #796400 | #9F5000 | #842B00 | |||||
#64A600 | #737300 | #977C00 | #BB5E00 | #A23400 | |||||
#73BF00 | #8C8C00 | #AE8F00 | #D26900 | #BB3D00 | |||||
#82D900 | #A6A600 | #C6A300 | #EA7500 | #D94600 | |||||
#8CEA00 | #C4C400 | #D9B300 | #FF8000 | #F75000 | |||||
#9AFF02 | #E1E100 | #EAC100 | #FF9224 | #FF5809 | |||||
#A8FF24 | #F9F900 | #FFD306 | #FFA042 | #FF8040 | |||||
#B7FF4A | #FFFF37 | #FFDC35 | #FFAF60 | #FF8F59 | |||||
#C2FF68 | #FFFF6F | #FFE153 | #FFBB77 | #FF9D6F | |||||
#CCFF80 | #FFFF93 | #FFE66F | #FFC78E | #FFAD86 | |||||
#D3FF93 | #FFFFAA | #FFED97 | #FFD1A4 | #FFBD9D | |||||
#DEFFAC | #FFFFB9 | #FFF0AC | #FFDCB9 | #FFCBB3 | |||||
#E8FFC4 | #FFFFCE | #FFF4C1 | #FFE4CA | #FFDAC8 | |||||
#EFFFD7 | #FFFFDF | #FFF8D7 | #FFEEDD | #FFE6D9 | |||||
#F5FFE8 | #FFFFF4 | #FFFCEC | #FFFAF4 | #FFF3EE | |||||
#613030 | #616130 | #336666 | #484891 | #6C3365 | |||||
#743A3A | #707038 | #3D7878 | #5151A2 | #7E3D76 | |||||
#804040 | #808040 | #408080 | #5A5AAD | #8F4586 | |||||
#984B4B | #949449 | #4F9D9D | #7373B9 | #9F4D95 | |||||
#AD5A5A | #A5A552 | #5CADAD | #8080C0 | #AE57A4 | |||||
#B87070 | #AFAF61 | #6FB7B7 | #9999CC | #B766AD | |||||
#C48888 | #B9B973 | #81C0C0 | #A6A6D2 | #C07AB8 | |||||
#CF9E9E | #C2C287 | #95CACA | #B8B8DC | #CA8EC2 | |||||
#D9B3B3 | #CDCD9A | #A3D1D1 | #C7C7E2 | #D2A2CC | |||||
#E1C4C4 | #D6D6AD | #B3D9D9 | #D8D8EB | #DAB1D5 | |||||
#EBD6D6 | #DEDEBE | #C4E1E1 | #E6E6F2 | #E2C2DE | |||||
#F2E6E6 | #E8E8D0 | #D1E9E9 | #F3F3FA | #EBD3E8 |
色碼表
#FFFFFF | #DDDDDD | #AAAAAA | #888888 | #666666 | #444444 | #000000 |
#FFB7DD | #FF88C2 | #FF44AA | #FF0088 | #C10066 | #A20055 | #8C0044 |
#FFCCCC | #FF8888 | #FF3333 | #FF0000 | #CC0000 | #AA0000 | #880000 |
#FFC8B4 | #FFA488 | #FF7744 | #FF5511 | #E63F00 | #C63300 | #A42D00 |
#FFDDAA | #FFBB66 | #FFAA33 | #FF8800 | #EE7700 | #CC6600 | #BB5500 |
#FFEE99 | #FFDD55 | #FFCC22 | #FFBB00 | #DDAA00 | #AA7700 | #886600 |
#FFFFBB | #FFFF77 | #FFFF33 | #FFFF00 | #EEEE00 | #BBBB00 | #888800 |
#EEFFBB | #DDFF77 | #CCFF33 | #BBFF00 | #99DD00 | #88AA00 | #668800 |
#CCFF99 | #BBFF66 | #99FF33 | #77FF00 | #66DD00 | #55AA00 | #227700 |
#99FF99 | #66FF66 | #33FF33 | #00FF00 | #00DD00 | #00AA00 | #008800 |
#BBFFEE | #77FFCC | #33FFAA | #00FF99 | #00DD77 | #00AA55 | #008844 |
#AAFFEE | #77FFEE | #33FFDD | #00FFCC | #00DDAA | #00AA88 | #008866 |
#99FFFF | #66FFFF | #33FFFF | #00FFFF | #00DDDD | #00AAAA | #008888 |
#CCEEFF | #77DDFF | #33CCFF | #00BBFF | #009FCC | #0088A8 | #007799 |
#CCDDFF | #99BBFF | #5599FF | #0066FF | #0044BB | #003C9D | #003377 |
#CCCCFF | #9999FF | #5555FF | #0000FF | #0000CC | #0000AA | #000088 |
#CCBBFF | #9F88FF | #7744FF | #5500FF | #4400CC | #2200AA | #220088 |
#D1BBFF | #B088FF | #9955FF | #7700FF | #5500DD | #4400B3 | #3A0088 |
#E8CCFF | #D28EFF | #B94FFF | #9900FF | #7700BB | #66009D | #550088 |
#F0BBFF | #E38EFF | #E93EFF | #CC00FF | #A500CC | #7A0099 | #660077 |
#FFB3FF | #FF77FF | #FF3EFF | #FF00FF | #CC00CC | #990099 | #770077 |
以名稱
aliceblue | antiquewhite | aqua | aquamarine |
azure | beige | bisque | black |
blanchedalmond | blue | blueviolet | brown |
burlywood | cadetblue | chartreuse | chocolate |
coral | cornflowerblue | cornsilk | crimson |
cyan | darkblue | darkcyan | darkgoldenrod |
darkgray | darkgreen | darkkhaki | darkmagenta |
darkolivegreen | darkorange | darkorchid | darkred |
darksalmon | darkseagreen | darkslateblue | darkslategray |
darkturquoise | darkviolet | deeppink | deepskyblue |
dimgray | dodgerblue | firebrick | floralwhite |
forestgreen | fuchsia | gainsboro | ghostwhite |
gold | goldnrod | gray | green |
greenyellow | honeydew | hotpink | indianred |
indigo | ivory | khaki | lavender |
lavenderblush | lawngreen | lemonchiffon | lightblue |
lightcoral | lightcyan | lightgoldenrodyellow | lightgreen |
lightgrey | lightpink | lightsalmon | lightseagreen |
lightskyblue | lightslategray | lightsteelblue | lightyellow |
lime | limegreen | linen | magenta |
maroon | mediumaquamarine | mediumblue | mediumorchid |
mediumpurple | mediumseagreen | mediumslateblue | mediumspringgreen |
mediumturquoise | mediumvioletred | midlightblue | mintcream |
mistyrose | moccasin | navajowhite | navy |
oldlace | olive | olivedrab | orange |
orangered | orchid | palegoldenrod | palegreen |
paleturquoise | palevioletred | papaywhip | peachpuff |
peru | pink | plum | powderblue |
purple | red | rosybrown | royalblue |
saddlebrown | salmon | sandybrown | seagreen |
seashell | sienna | silver | skyblue |
slateblue | slategray | snow | springgreen |
steelblue | tan | teal | thistle |
tomato | turquoise | violet | wheat |
white | whitesmoke | yellow | yellowgreen |
2017年9月26日 星期二
判斷學區內學區外
戶籍資料格式
忠孝里001鄰忠孝路 |
中原里015鄰正神路 |
內壢里002鄰成功路 |
仁愛路75巷 |
中原里011鄰興農路 |
判斷方式:
1. 沒有里、鄰 一律為學區外
2. 內壢、福德、成功里 一律為學區內
=IF(OR(OR(LEFT(F9,2)="內壢",LEFT(F9,2)="成功"),LEFT(F9,2)="福德"),1,0)
3.成功里學區為19鄰以前,中原里為除了9、10鄰以外
SEARCH("里",F9,1) 找出里的位置
MID(F9,SEARCH("里",F9)+1,SEARCH("鄰",F9)-SEARCH("里",F9)-1),這樣就可以取出鄰,放入H欄
=IF(AND(LEFT(F9,2)="成功",H9*1<20),1,0)
=IF(AND(LEFT(F9,2)="中原",OR(H9*1<9,H9*1>10)),1,0)
兩式合併
=IF(OR( AND(LEFT(F9,2)="成功",H9*1<20),AND(LEFT(F9,2)="中原",OR(H9*1<9,H9*1>10)),1,0)
2017年9月25日 星期一
2017年9月22日 星期五
區塊數字資料的儲存
運用於成績資料的匯入
$arr = preg_split('//', $_POST['nor_score_all'], -1, PREG_SPLIT_NO_EMPTY);
$arr2=array();
foreach($arr as $v){
if(ord ($v)==46 || (ord ($v)>=48 && ord ($v)<=57) ){
$str.=$v;
}else{
if($k++==3){
array_push($arr2, '');
$k=0;
}
if($str!='') {
array_push($arr2, $str);
$k=0;
}
$str='';
}
}
if($str) array_push($arr2, $str);
//該班學生列表
$smb_arr=& $xscm->class_smb_arr($gc_year , $gc_seme , $gc_grad , $gc_class);
foreach($smb_arr as $key => $smb_sn){
//echo $smb_sn."==>";
//檢查該生該次平時成績紀錄是否存在
$one_nor=$xscm->one_nor_score($_POST['scm_nor_title_sn'],$smb_sn);
//tool::print_r($one_nor);
if($one_nor['scm_nor_sn']){
//已經存在,用更新的
if($one_nor['scm_nor_score']==$arr2[$key]) continue;
if($arr2[$key]==''){
$sql="update ".$xoopsDB->prefix("sxs_scorem_nor")." set scm_nor_score=NULL where smb_sn='$smb_sn' and scm_nor_title_sn='{$_POST['scm_nor_title_sn']}' ";
}else{
$sql="update ".$xoopsDB->prefix("sxs_scorem_nor")." set scm_nor_score='{$arr2[$key]}' where smb_sn='$smb_sn' and scm_nor_title_sn='{$_POST['scm_nor_title_sn']}' ";
}
}
else{
//新增一個
if($arr2[$key]=='') $sql="insert into ".$xoopsDB->prefix("sxs_scorem_nor")."(smb_sn,scm_nor_score,scm_nor_title_sn) values('$smb_sn', NULL ,'{$_POST['scm_nor_title_sn']}')";
else $sql="insert into ".$xoopsDB->prefix("sxs_scorem_nor")."(smb_sn,scm_nor_score,scm_nor_title_sn) values('$smb_sn','{$arr2[$key]}','{$_POST['scm_nor_title_sn']}')";
}
$rs=$CONN->Execute($sql) or redirect_header($pageurl, 5, mysql_error()."<br />
"._MD_SQL_ERR."<br />
$sql");
//echo $sql."<br />
";
$arr = preg_split('//', $_POST['nor_score_all'], -1, PREG_SPLIT_NO_EMPTY);
$arr2=array();
foreach($arr as $v){
if(ord ($v)==46 || (ord ($v)>=48 && ord ($v)<=57) ){
$str.=$v;
}else{
if($k++==3){
array_push($arr2, '');
$k=0;
}
if($str!='') {
array_push($arr2, $str);
$k=0;
}
$str='';
}
}
if($str) array_push($arr2, $str);
//該班學生列表
$smb_arr=& $xscm->class_smb_arr($gc_year , $gc_seme , $gc_grad , $gc_class);
foreach($smb_arr as $key => $smb_sn){
//echo $smb_sn."==>";
//檢查該生該次平時成績紀錄是否存在
$one_nor=$xscm->one_nor_score($_POST['scm_nor_title_sn'],$smb_sn);
//tool::print_r($one_nor);
if($one_nor['scm_nor_sn']){
//已經存在,用更新的
if($one_nor['scm_nor_score']==$arr2[$key]) continue;
if($arr2[$key]==''){
$sql="update ".$xoopsDB->prefix("sxs_scorem_nor")." set scm_nor_score=NULL where smb_sn='$smb_sn' and scm_nor_title_sn='{$_POST['scm_nor_title_sn']}' ";
}else{
$sql="update ".$xoopsDB->prefix("sxs_scorem_nor")." set scm_nor_score='{$arr2[$key]}' where smb_sn='$smb_sn' and scm_nor_title_sn='{$_POST['scm_nor_title_sn']}' ";
}
}
else{
//新增一個
if($arr2[$key]=='') $sql="insert into ".$xoopsDB->prefix("sxs_scorem_nor")."(smb_sn,scm_nor_score,scm_nor_title_sn) values('$smb_sn', NULL ,'{$_POST['scm_nor_title_sn']}')";
else $sql="insert into ".$xoopsDB->prefix("sxs_scorem_nor")."(smb_sn,scm_nor_score,scm_nor_title_sn) values('$smb_sn','{$arr2[$key]}','{$_POST['scm_nor_title_sn']}')";
}
$rs=$CONN->Execute($sql) or redirect_header($pageurl, 5, mysql_error()."<br />
"._MD_SQL_ERR."<br />
$sql");
//echo $sql."<br />
";
2017年9月20日 星期三
未上傳之前先用javascript檢查檔案
HTML設計
設計按鈕格式,onclick先檢查,若正確才儲存
<input onclick="checktosave();" type="button" value="儲存" />
//檢查上船附檔名及檔案大小
function checktosave() {
var f = document.getElementById('upfile');
var uploadpath=f.value;
var ext = uploadpath.substring(uploadpath.lastIndexOf('.') + 1, uploadpath.length);
var ext = ext.toLowerCase();
if (ext=='odp') {
filesize = f.files.item(0).size;
if (filesize>5*1024*1024) {
alert('檔案太大,必須小於5M');
} else {
document.getElementById('saveForm').submit();
}
} else {
alert('必須是ODP檔');
}
}
//檢查圖片
var _URL = window.URL || window.webkitURL;
var h=0;
var w=0;
$('#upfile').change(function(e) {
var image, file;
if ((file = this.files[0])) {
image = new Image();
image.onload = function() {
w=this.width;
h=this.height;
};
image.src = _URL.createObjectURL(file);
}
});
function checktosave() {
var f = document.getElementById('upfile');
var uploadpath=f.value;
//var pos = uploadpath.lastIndexOf('.') + 1;
var ext = uploadpath.substring(uploadpath.lastIndexOf('.') + 1, uploadpath.length);
var ext = ext.toLowerCase();
//filesize = f.files.item(0).size;
if (ext=='bmp' || ext=='png' || ext=='jpg' || ext=='jepg' || ext=='gif') {
if (w!= '{$default_width}' || h!= '{$default_height}' )
alert('圖片的大小必須是 {$default_width} * {$default_height} ');
else {
document.getElementById('saveForm').submit();
}
} else {
alert('必須是圖形檔');
}
}
運用到學生作品版
$fileext = $row['fileext'];
if ($fileext=='') { //任何設定
$ext_str='true';
} else {
$ext_str='';
$ext_arr = explode(',',$fileext);
foreach ($ext_arr as $e) {
$ext_str .= " ext=='{$e}' || ";
}
//刪除後三個字元
$ext_str = substr($ext_str,0,strlen($ext_str)-3);
}
$op_bar.="<br />
<div class="btn-group">
<form action="?do=quickupload&sn=$sn" class="form-inline" enctype="multipart/form-data" id="saveForm" method="POST">
<div class="form-group">
<label for="files">上傳{$row['cfile']} {$row['fileext']}檔案</label> <input class="form-control" id="files" multiple="" name="upfiles[]" type="file" /></div>
<div class="form-group">
<button class="btn btn-default" onclick="checktosave();" type="button">交作業</button></div>
</form>
</div>
<script>
function checktosave() {
var f = document.getElementById('upfile');
var uploadpath=f.value;
var ext = uploadpath.substring(uploadpath.lastIndexOf('.') + 1, uploadpath.length);
var ext = ext.toLowerCase();
if ({$ext_str}) {
filesize = f.files.item(0).size;
if (filesize<10 || filesize>12*1024*1024 ) {
if (filesize<10)
alert('檔案太小,必須先儲存');
else
alert('檔案太大,必須小於12M');
} else {
document.getElementById('saveForm').submit();
}
} else {
alert('檔案格式錯誤');
}
}
</script>
";
設計按鈕格式,onclick先檢查,若正確才儲存
<input onclick="checktosave();" type="button" value="儲存" />
//檢查上船附檔名及檔案大小
function checktosave() {
var f = document.getElementById('upfile');
var uploadpath=f.value;
var ext = uploadpath.substring(uploadpath.lastIndexOf('.') + 1, uploadpath.length);
var ext = ext.toLowerCase();
if (ext=='odp') {
filesize = f.files.item(0).size;
if (filesize>5*1024*1024) {
alert('檔案太大,必須小於5M');
} else {
document.getElementById('saveForm').submit();
}
} else {
alert('必須是ODP檔');
}
}
//檢查圖片
var _URL = window.URL || window.webkitURL;
var h=0;
var w=0;
$('#upfile').change(function(e) {
var image, file;
if ((file = this.files[0])) {
image = new Image();
image.onload = function() {
w=this.width;
h=this.height;
};
image.src = _URL.createObjectURL(file);
}
});
function checktosave() {
var f = document.getElementById('upfile');
var uploadpath=f.value;
//var pos = uploadpath.lastIndexOf('.') + 1;
var ext = uploadpath.substring(uploadpath.lastIndexOf('.') + 1, uploadpath.length);
var ext = ext.toLowerCase();
//filesize = f.files.item(0).size;
if (ext=='bmp' || ext=='png' || ext=='jpg' || ext=='jepg' || ext=='gif') {
if (w!= '{$default_width}' || h!= '{$default_height}' )
alert('圖片的大小必須是 {$default_width} * {$default_height} ');
else {
document.getElementById('saveForm').submit();
}
} else {
alert('必須是圖形檔');
}
}
運用到學生作品版
$fileext = $row['fileext'];
if ($fileext=='') { //任何設定
$ext_str='true';
} else {
$ext_str='';
$ext_arr = explode(',',$fileext);
foreach ($ext_arr as $e) {
$ext_str .= " ext=='{$e}' || ";
}
//刪除後三個字元
$ext_str = substr($ext_str,0,strlen($ext_str)-3);
}
$op_bar.="<br />
<div class="btn-group">
<form action="?do=quickupload&sn=$sn" class="form-inline" enctype="multipart/form-data" id="saveForm" method="POST">
<div class="form-group">
<label for="files">上傳{$row['cfile']} {$row['fileext']}檔案</label> <input class="form-control" id="files" multiple="" name="upfiles[]" type="file" /></div>
<div class="form-group">
<button class="btn btn-default" onclick="checktosave();" type="button">交作業</button></div>
</form>
</div>
<script>
function checktosave() {
var f = document.getElementById('upfile');
var uploadpath=f.value;
var ext = uploadpath.substring(uploadpath.lastIndexOf('.') + 1, uploadpath.length);
var ext = ext.toLowerCase();
if ({$ext_str}) {
filesize = f.files.item(0).size;
if (filesize<10 || filesize>12*1024*1024 ) {
if (filesize<10)
alert('檔案太小,必須先儲存');
else
alert('檔案太大,必須小於12M');
} else {
document.getElementById('saveForm').submit();
}
} else {
alert('檔案格式錯誤');
}
}
</script>
";
訂閱:
文章 (Atom)