阻止readonly按下backspace跳出页面 |
js |
|
$("textarea[readonly]").keydown(function(e) {
e.preventDefault();
});
|
从千位符转换回来 |
js |
|
/**
* 从千位符转换回来
*/
function RetainedBackPlaces(num) {
return num.replaceAll(",","");
}
/**
* 替换所有字符的方法
* @returns
*/
String.prototype.replaceAll = function (AFindText,ARepText){
var raRegExp = new RegExp(AFindText,"g");
return this.replace(raRegExp,ARepText);
};
|
千位符、保留小数位数 |
js |
|
/**
* 处理数字:千位符、保留小数位数
* @param num 值
* @param del 小数位
* @param o o为true返回值为正数,否则为负数
* @returns {String}
*/
function RetainedDecimalPlaces(num, del, o) {
try {
num += "";
//num = _round(parseFloat(num),del)+""; //保留小数并四舍五入
var str = "";
if (!o) {
if (num.substring(0, 1) == "-") str = "-";
}
//清除字符串中的非数字 非.字符
num = num.replace(/[^0-9|\.]/g, "");
//清除字符串开头的0
if (/^0+/) num = num.replace(/^0+/, "");
//为整数字符串在末尾添加.0000
if (!/\./.test(num)) num += ".0000";
//字符以.开头时,在开头添加0
if (/^\./.test(num)) num = "0" + num; num += "0000"; //在字符串末尾补零
if (del == 2) num = num.match(/\d+\.\d{3}/)[0];
if (del == 4) num = num.match(/\d+\.\d{4}/)[0];
var num1 =num*1000;
var num2= num1/10;
var num3 = Math.round(num2);
var num4= num3/100;
num = num4;
num = _round(parseFloat(num),del)+"";
//千位符
while (/\d{4}(\.|,)/.test(num)) //符合条件则进行替换
num = num.replace(/(\d)(\d{3}(\.|,))/, "$1,$2"); //每隔3位添加一个
return str + num;
} catch (e) {
alert(e);
}
}
|
求两个数的最大公约数 |
js |
|
/**
* 求最大公约数
* @return
*/
function getMaxGY(m,n){
var temp=n;
while (n!=0)
{
temp=m%n;
m=n;
n=temp;
}
return m;
}
|
Oracle创建表空间脚本 |
oracle |
|
create tablespace TS_GK_WB[表空间名]
datafile 'F:\app\FLM\oradata\local_yydl[实例名]\TS_GK_WB[表空间名].DBF' size 100M
autoextend on next 30M maxsize unlimited logging
extent management local autoallocate
segment space management auto;
|
年月日时分秒的即时显示 |
js |
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>年月日时分秒的即时显示-www.111cn.net</title>
</head>
<body onload=startclock()>
<form name="clock">
<script language="JavaScript">
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;}
function startclock () {
stopclock();
showtime();}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var (www.111cn.net)timeValue = now.getYear()+"年"+(now.getMonth()+1)+"月"+now.getDate()+"日" +((hours >= 12) ? " 下午 " : " 上午 " )
timeValue += ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
document.clock.thetime.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;}
</script>
<input name="thetime" style="font-size: 9pt;color:#000000;border:1px solid #FFFFFF; ; " size="28"></form>
</body>
</html>
|
数据库连接数 |
oracle |
|
//查看数据库允许的最大连接数
select value from v$parameter where name = 'processes';
//查看当前的连接数
select count(*) from v$process;
//修改最大连接数
alter system set processes = 300 scope = spfile;
//查看oracle的并发连接数
select count(*) from v$session where status='ACTIVE';
|
删除系统锁定的记录 |
oracle |
|
ALTER system KILL session 'SID,serial#';
|
查询锁定的表 |
oracle |
|
SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username,
l.os_user_name,s.machine, s.terminal, o.object_name, s.logon_time
FROM v$locked_object l, all_objects o, v$session s
WHERE l.object_id = o.object_id
AND l.session_id = s.sid
ORDER BY sid, s.serial# ;
|
排序 冒泡排序 |
java |
排序 冒泡排序 |
package test;
public class Sort {
public static void main(String[] args) {
bubbleSort();
}
public static void bubbleSort() {
int a[] = { 9, 8, 2, 6, 4, 0, 3, 7, 5, 1 };
for (int k = 0; k < a.length; k++) {
System.out.print(a[k] + "--");
}
System.out.println();
int temp;
for (int i = 0; i < a.length - 1; i++) { // 把最大的放后面,所以最后一个不考虑
for (int j = 0; j < a.length - 1 - i; j++) {
if (a[j] > a[j + 1]) { // 没有对比的挨着对比
temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
for (int k = 0; k < a.length; k++) {
System.out.print(a[k] + "--");
}
System.out.println();
}
}
}
|
只用一个循环 打印乘法表 |
java |
只用一个循环 打印乘法表 |
package com.test;
public class Test {
public static void main(String[] args) {
// 一次设置两个变量
for (int i = 1, j = 1; j <= 9; i++) {
System.out.print(i + "*" + j + "=" + i * j + " ");
if (i == j) {
i = 0; // 为什么要等于0?因为执行一个循环以后,i会执行i++,会加1
j++;
System.out.println();
}
}
}
}
|
删除.svn脚本 |
script |
|
@for /r . %%I in (.svn) do if exist "%%I" rd/s/q "%%I"
|
父页面调用子页面方法(iframe) |
js |
|
<iframe scrolling="no" frameborder="1" id="letter_iframe" name="letter_iframe"
style="overflow:hidden;width: 1340px;height: 670px;">
</iframe>
letter_iframe.window.setUser(node.text,node.id);//父页面调用子页面setUser方法
parent.window.父页面方法名//子页面调用父页面方法
|
验证结束日期不能小于开始日期~格式:yyyy-mm-dd hh:mm |
js |
|
var startTime = $("#startTime").datebox("getValue");
var endTime = $("#endTime").datebox("getValue");
var stTime = startTime.substring(0, 10).split('-');
var enTime = endTime.substring(0, 10).split('-');
var sTime = stTime[1] + '-' + stTime[2] + '-' + stTime[0] + ' ' + startTime.substring(10,19);
var eTime = enTime[1] + '-' + enTime[2] + '-' + enTime[0] + ' ' + endTime.substring(10, 19);
var count = (Date.parse(eTime) - Date.parse(sTime)) / 3600 / 1000;
如果count小于0,那么结束日期大;
如果count大于0,那么结束日期小;
|
取tr的ID,控制tr隐藏显示 |
js |
|
$("#showEndTime").css('display', 'none');隐藏
$("#showEndTime").css('display', '');显示
|
jQuery 页面加载初始化的方法 |
js |
|
$(document).ready(function(){
alert("第一种方法");
});
$(function(){
alert("第二种方法");
});
JQuery(function($){
alert("第三种方法");
});
在body里写onload,在脚本里写:
window.onload=function(){
//要初始化的东西
}
|
计时器 |
js |
|
setInterval("show()",3000);//意思是每隔3秒执行一次show()方法
setTimeout("show()",3000);//意思是定时执行,3秒后执行show()方法
|
动态获取系统时间 |
js |
|
<script type="text/javascript">
//获取系统当前时间--格式:
window.onload =function showTime(){
var now = new Date();//获取当前时间
var year = now.getFullYear();//年
var month = now.getMonth() + 1;//月
var date = now.getDate();//日
var day = now.getDay();//星期
var hour = now.getHours();//时
var minute = now.getMinutes();//分
var second = now.getSeconds();//秒
if(day == 0)
day="星期日";
else if(day == 1)
day="星期一";
else if(day == 2)
day="星期二";
else if(day == 3)
day="星期三";
else if(day == 4)
day="星期四";
else if(day == 5)
day="星期五";
else if(day == 6)
day="星期六";
if(hour<10)
hour="0"+hour;
if(minute<10)
minute="0"+minute;
if(second<10)
second="0"+second;
if(date<10)
date="0"+date;
if(month<10)
month="0"+month;
document.getElementById("time").innerHTML="期:"+year+"年"+month+"月"+date+"日"+" "+day+" "+hour+":"+minute+":"+second; //刷新时间
setTimeout('showTime()',1000);</script>
<div id="time"></div>
|
JS的toFixed方法 |
js |
|
var num = 13.259;
var result = new Number(num);
var lastResult = result.toFixed(2);//保留两位小数并进行四舍五入
|
检验输入的日期格式是否正确 |
js |
|
function checkDate()
{
var strDate = document.getElementById("remindTime").value;
var result = strDate.match(/((^((1[8-9]\d{2})|([2-9]\d{3}))(-)(10|12|0?[13578])(-)(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))(-)(11|0?[469])(-)(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))(-)(0?2)(-)(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)(-)(0?2)(-)(29)$)|(^([3579][26]00)(-)(0?2)(-)(29)$)|(^([1][89][0][48])(-)(0?2)(-)(29)$)|(^([2-9][0-9][0][48])(-)(0?2)(-)(29)$)|(^([1][89][2468][048])(-)(0?2)(-)(29)$)|(^([2-9][0-9][2468][048])(-)(0?2)(-)(29)$)|(^([1][89][13579][26])(-)(0?2)(-)(29)$)|(^([2-9][0-9][13579][26])(-)(0?2)(-)(29)$))/);
if(result==null)
{
alert("请输入正确的日期格式(例如:2013-01-01)!\r\n 或从时间列表中选择日期!");
return true;
}
return false;
}
|
生成随机数 |
js |
|
double a = Math.random()*1000;//*1000生成三位随机数(0-999)
a = Math.ceil(a);
int randomNum = new Double(a).intValue();
System.out.println(randomNum);
|
查询7天内过生日的人员 |
sql |
|
select realName,birthday from 表名 where cast(SUBSTRING(CONVERT(varchar(12),BIRTHDAY,112),5,7) as int)
between cast(SUBSTRING(CONVERT(varchar(12),getdate(),112),5,7) as int) and cast(SUBSTRING(CONVERT(varchar(12),getdate()+7,112),5,7) as int)
convert用法:
convert(dataType,date,style)==>dataType:数据类型,date:日期,style:转换后日期的格式;getdate()==>获取当前时间
style=101时:日期格式为:03/08/2013
style=112时:日期格式为:20130308
style=121时:日期格式为:2013-03-08 10:28:18.107 精确到毫秒
style= 23时:日期格式为:2013-03-08
style=120时:日期格式为:2013-03-08 10:30:53
style= 8时:日期格式为:10:32:37 更多资料上网找[dataType可以用varchar(100)]
SubString用法:
SubString(字符串,开始截取位置(包含当前位置),需要截取的字符串长度)
例如:SubString("20130308",5,4) //截取字符串20130308,从第五个位置开始截取,截取第五个位置后4位。结果为:0308
|