Code

radio按钮的全选 <script language="javascript">
  function CheckAll(obj, oValue){
   var oBool = false;
   var oTable = document.all['oTable'];
   for (var i=1; i<oTable.rows.length; i++) {
     for (var j=0; j<oTable.rows[i].cells[0].children.length; j++) {
       oBool = (oTable.rows[i].cells[0].children[j].tagName=='INPUT') && (oTable.rows[i].cells[0].children[j].type=='radio') && (oTable.rows[i].cells[0].children[j].value==oValue);
       if (oBool) {
         oTable.rows[i].cells[0].children[j].checked = true;
       }
     }
   }
   for (var i=0; i<oTable.rows[0].cells[0].children.length; i++)
     oTable.rows[0].cells[0].children[i].checked = (oTable.rows[0].cells[0].children[i] == obj);
  }
</script>
<table id="oTable">
<tr>
<td> <input type="checkbox" name="a" value="1" onclick="CheckAll(this, value);"> 全优<input type="checkbox" name="a" value="2" onclick="CheckAll(this, value);"> 全良<input type="checkbox" name="a" value="3" onclick="CheckAll(this, value);">全及格 </td>
</tr>
<tr>
<td> <input type="radio" name="a" value="1"> 优<input type="radio" name="a" value="2"> 良 <input type="radio" name="a" value="3"> 及格 </td>
</tr>
<tr>
<td> <input type="radio" name="b" value="1"> 优<input type="radio" name="b" value="2"> 良 <input type="radio" name="b" value="3"> 及格 </td>
</tr>
<tr>
<td> <input type="radio" name="c" value="1"> 优<input type="radio" name="c" value="2"> 良 <input type="radio" name="c" value="3"> 及格 </td>
</tr>
<tr>
<td> <input type="radio" name="d" value="1"> 优<input type="radio" name="d" value="2"> 良 <input type="radio" name="d" value="3"> 及格 </td>
</tr>
<tr>
<td> <input type="radio" name="e" value="1"> 优<input type="radio" name="e" value="2"> 良 <input type="radio" name="e" value="3"> 及格 </td>
</tr>
<tr>
<td> <input type="radio" name="f" value="1"> 优<input type="radio" name="f" value="2"> 良 <input type="radio" name="f" value="3"> 及格 </td>
</tr>
</table> 
网页源代码转为UBB代码 JS <SCRIPT language=JavaScript1.2>
function html_trans(str) {
        str = str.replace(/\r/g,"");
        str = str.replace(/on(load|click|dbclick|mouseover|mousedown|mouseup)="[^"]+"/ig,"");
        str = str.replace(/<script[^>]*?>([\w\W]*?)<\/script>/ig,"");
        
        str = str.replace(/<a[^>]+href="([^"]+)"[^>]*>(.*?)<\/a>/ig,"\n[url=$1]$2[/url]\n");
        
        str = str.replace(/<font[^>]+color=([^ >]+)[^>]*>(.*?)<\/font>/ig,"\n[color=$1]$2[/color]\n");
        
        str = str.replace(/<img[^>]+src="([^"]+)"[^>]*>/ig,"\n[img]$1[/img]\n");
        
        str = str.replace(/<([\/]?)b>/ig,"[$1b]");
        str = str.replace(/<([\/]?)strong>/ig,"[$1b]");
        str = str.replace(/<([\/]?)u>/ig,"[$1u]");
        str = str.replace(/<([\/]?)i>/ig,"[$1i]");
        
        str = str.replace(/&nbsp;/g," ");
        str = str.replace(/&amp;/g,"&");
        str = str.replace(/&quot;/g,"\"");
        str = str.replace(/&lt;/g,"<");
        str = str.replace(/&gt;/g,">");
        
        str = str.replace(/<br>/ig,"\n");
        str = str.replace(/<[^>]*?>/g,"");
        str = str.replace(/\[url=([^\]]+)\]\n(\[img\]\1\[\/img\])\n\[\/url\]/g,"$2");
        str = str.replace(/\n+/g,"\n");
        
        return str;
}

function trans(){
        var str = "";
        rtf.focus();
        rtf.document.body.innerHTML = "";
        rtf.document.execCommand("paste");
        str = rtf.document.body.innerHTML;
        if(str.length == 0) {
                alert("剪切版不存在超文本数据!");
                return "";
        }
        return html_trans(str);
}
</SCRIPT>  
实现从指定时间向下推N个月的函数

<?
/*
 *  作者:心灯
 *  功能:实现从指定时间向下推N个月的函数
 *  month($ymd,$len) $ymd时间,$len推出几个月
 *  $ymd='2005-01-01';
 */
function month($ymd='',$len='12'){
    $month  = array();
    $lang   = $lang."<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\">";
    if($ymd){//判断时间格式是否正确
        if(!ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})",$ymd)){           
            echo "<script>alert('函数参数中的日期格式不对');history.back()</script>";
            exit;
        }
    }
    if($len){
        if(!ereg("[0-9]+",$len)){           
            echo $lang."<script>alert('函数中的时间长度中含有非法字段');history.back()</script>";
            exit;
        }
    }
    for($i=0;$i<$len;$i++){
        if($i==0){
            $mktime = $ymd?strtotime($ymd):time();
        }
        $month[] = date("Y-m",$mktime);//可以根据需要来设计置你要的格式
        $day = date("t",$mktime);
        if($i==0)
            $reday = date("d",$mktime);
        else
            $reday = $day;
        $t1   = $mktime;
        $mktime=date("Y-m-d",mktime(date("H",$t1),date("i",$t1),date("s",$t1),date("m",$t1),date("d",$t1)-$reday,date("Y",$t1)));
        $mktime =strtotime($mktime);       
    }
    return $month;
}
$month = month('', 3);
foreach($month as $key => $v){
    echo $v."<br>";
}
?>

需要过滤HTML标记,写了个函数,可以实现简单的过滤...
    摘要:可以实现简单的过滤... 用着勉强还行    (全文共1054字)——点击此处阅读全文

第1页,共1页