日期与色彩选择器
代码:
以下是引用片段: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>infocn.org 色彩与日期 QQ107800843爱德华:失业中</title> <style type="text/css"> <!-- #date_ td,#date_ th{padding:3px;font-weight: normal;} #date_ tr:hover td,#date_ tr:hover th{background-color:#ffc;}#date_ tr td:hover{background-color:#fcf;} #date_ u{text-decoration: none;} --> </style> </head> <body> 日期 <input name="date" type="text" size="24" maxlength="63" t="title" value="2000-1-1" /> <input name="date" type="text" size="24" maxlength="63" t="title" value="2000-1-1" /> <input name="date" type="text" size="24" maxlength="63" t="title" value="2009-1-1" /> <input name="date" type="text" size="24" maxlength="63" t="title" value="2000-1-1" /> <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />色彩 <input name="date" type="text" size="24" maxlength="63" t="title" value="#FFFFFF" /> <input name="date" type="text" size="24" maxlength="63" t="title" value="#FFFFFF" /> <input name="date" type="text" size="24" maxlength="63" t="title" value="#FFFFFF" /> <input name="date" type="text" size="24" maxlength="63" t="title" value="#FFFFFF" /> <script type="text/javascript"> $tmp=[]; function $(id,n){return n==null?document.getElementById(id):document.getElementsByName(id)[n]} //日期 function DATE(id){ temp(’<table id="’+id+’" title="" summary="" ’<tr><th>日</th><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th></tr><tbody bgcolor="#FFFFFF"><tr><td></td><td></td><td></td><td></td><td></td><td></td><td> </td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td> </td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td> </td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td> </td></tr><tr><td></td><td></td><td></td><td></td><td></td><td></td><td> </td></tr><tr><td></td><td></td><td></td><td>年</td><td>月</td><td>关</td><td>今</td></tr></tbody></table>’); date(id)} function date(id,date,t){ var D=new Date(),o=$(id);if(arguments.length>1){s=date.split(/\D+/i);for(i=s.length;i<3;)s[i++]=1;if(s[1])s[1]--; if(arguments.length>2){if(t==1)s[0]--;if(t==2)s[1]--;if(t==3)s[1]++;if(t==4)s[0]++;}D=new Date(s[0],s[1],s[2]);} var y=D.getFullYear(),m=D.getMonth()+1,d=D.getDate(),w=D.getDay(),w=D.getDay();o.title=y+’-’+m; var M=[0,31,(y%4==0&&y%100!=0)||y%400==0?29:28,31,30,31,30,31,31,30,31,30,31],l=(36+w-d)%7; for(o=o.getElementsByTagName("td"),l1=l+M[m]+1,i=1;i<38;i++){o[i].innerText=(i>l&&i<l1)?i-l:’ ’;o[i].style.backgroundColor=i-l==d?’#f66’:’’;}o[0].innerText=y+’-’+m;} function date_(event,s,id){var O=$tmp[id],o=event.srcElement?event.srcElement:event.originalTarget;if (o.nodeName.toLowerCase()==’td’) {if(o.innerHTML==’关’)o.parentNode.parentNode.parentNode.style.left=’-900px’;if(o.innerHTML==’今’)date(id); $s=parseInt(o.innerHTML);if(!isNaN($s)&&$s>0&&$s<32){O.value=s+’-’+$s;o.parentNode.parentNode.parentNode.style.left=’-900px’;}}} function Focus(id,o){$tmp[id]=o;var t=o.offsetTop+o.offsetHeight,l=o.offsetLeft;while(o=o.offsetParent){t+=o.offsetTop;l+=o.offsetLeft;} var c=$(id);if(c){c.style.left= l+’px’;c.style.top= t+’px’;c.style.display=’block’;c.focus();$tmp[id+’_xy’]=l+’,’+t}} //色彩 function color(id){var t=[],r=[’fc’,’96’,’30’],g=’fc96300369cf’,b=’fc96300369cffc9630’,I=0;for(i=0;i<12;i++){for(l=0;l<18;l++)t[++I]=r[parseInt(l/6)].charAt(parseInt(i/6))+g.charAt(i)+b.charAt(l);t[I]+=’</tr>\n<tr>’;}t[I]=t[I].slice(0,3); temp(’<table id="’+id+’" function color_(event,id){var O=$tmp[id],o=event.srcElement?event.srcElement:event.originalTarget;if(o.nodeName.toLowerCase()==’td’&&O!=null) {O.value=o.bgColor;O.style.backgroundColor=o.bgColor;o.parentNode.parentNode.parentNode.style.left=’-900px’;}if (o.nodeName.toLowerCase()==’caption’&&O!=null)o.parentNode.style.left=’-900px’;} function temp(s){if(!$(’_temp_’)) {var o=document.createElement("div");document.body.appendChild(o); //o.style.display=’none’; o.id=’_temp_’; o.style.position=’absolute’; //o.style.left=’-900px’; } $(’_temp_’).insertAdjacentHTML(’afterEnd’,s)} /*cc_on window.onunload=CollectGarbage;*/ /*if(_jscript) document.nativeGetElementById=document.getElementById;document.getElementById = function(id){ var elem = document.nativeGetElementById(id);if(elem){if(elem.attributes[’id’].value==id){return elem;}else{for(var i=1;i<document.all[id].length;i++){if(document.all[id][i].attributes[’id’].value == id){return document.all[id][i];}}}} return null;}; //$("__ie_onload").onreadystatechange=function(){if(this.readyState == "complete")init();}; else */ //Firefox不支持条件注释 //document.addEventListener("DOMContentLoaded", init, false); //在DOM调用完后调用init HTMLElement.prototype.insertAdjacentHTML=function(where,htmlStr){var r=this.ownerDocument.createRange();r.setStartBefore(this);this.insertAdjacentElement(where,r.createContextualFragment(htmlStr))} HTMLElement.prototype.insertAdjacentElement=function(where,o){switch(where){case "beforeBegin":this.parentNode.insertBefore(o,this);break;case "afterBegin":this.insertBefore(o,this.firstChild); break;case "beforeEnd":this.appendChild(o);break;case "afterEnd":if(this.nextSibling)this.parentNode.insertBefore(o,this.nextSibling);else this.parentNode.appendChild(o);break}} HTMLElement.prototype.__defineSetter__("outerHTML",function(sHTML){ var r=this.ownerDocument.createRange();r.setStartBefore(this);var df=r.createContextualFragment(sHTML);this.parentNode.replaceChild(df,this);return sHTML}); HTMLElement.prototype.__defineGetter__("outerHTML",function(){var attr,attrs=this.attributes,str="<"+this.tagName;for(var i=0;i<attrs.length;i++){attr=attrs[i];if(attr.specified)str+=" "+attr.name+’="’+attr.value+’"’}return str+">"+this.innerHTML+"</"+this.tagName+">"; }); HTMLElement.prototype.__defineSetter__("innerText",function(sHTML){this.textContent=sHTML;}); /*end */ DATE(’date_’);color(’color_’); </script> </body> </html> |