【原创】ASP开发技巧集锦四

** 31. ** ** 确认操作 ** **

**

function ConfirmDel()
{
if(confirm(" 确定要删除吗?一旦删除将不能恢复! "))
return true;
else
return false;
}

 1<form action="Del.asp" method="Post" name="del" onsubmit="return ConfirmDel();">
 2
 3============================================================== 
 4
 5我自己用的一个。    
 6function ConfirmReset()   
 7{   
 8if(confirm("  确定取消操作吗?一旦取消操作将不能恢复!  "))   
 9window.form1.reset();   
10// return true;   
11}   
12<a href="javascript:ConfirmReset();"><img src="button_cance.gif"/></a>
13
14** 32\.  ** ** indexOf()  ** ** 用法  ** **
15
16**
17
18&lt; 字符串对象  &gt;.indexOf(&lt; 另一个字符串对象  &gt;[, &lt; 起始位置  &gt;])  ; 
19
20该方法从  &lt; 字符串对象  &gt; 中查找  &lt; 另一个字符串对象  &gt; (如果给出  &lt; 起始位置  &gt; 就忽略之前的位置),如果找到了,就返回它的位置,没有找到就返回“  -1  ”。所有的“位置”都是从零开始的。    
21eg. Str.indexOf(“AP”)&gt;-1  说明  str  中存在  ”AP”  字符串 
22
23** 33\.  ** ** 生成流水号  ** **
24
25**

if request.form("Modf") &lt;&gt; "" then
Dim rs
Dim sql
Dim BugID
dim today
today=date()
toyear=year(today)
toyear=toyear10000
tomonth= month(today)
tomonth=tomonth
100
tonow=day(today)
Serialnum = toyear + tomonth + tonow
Serialnum = Serialnum*10000+1

set rs = Server.CreateObject("ADODB.recordset")
sql = "select top 1 * from buglist order by SubmitDate desc"
rs.open sql,conn,1,3
if not rs.eof then
Dim OldSerialnum
OldSerialnum = Rs("BugID")
OldSerialnum = right(OldSerialnum,12)
Serial = right(Serialnum,12)
if OldSerialnum - Serial &gt;= 0 then
Serialnum = OldSerialnum + 1
end if
end if
BugID = "ES"&amp;request("ProductVersion")&amp;Serialnum

** 34. ** ** 响应回车 ** **

**

function getdata(what,whatid)
{
if (event.keyCode==13)
……
<input name="SerialNum&lt;%=i " onkeydown="getdata(window.form1.SerialNum =i .value, =i

  1
  2** 35\.  ** ** 关闭窗口前刷新父页面  ** **
  3
  4**
  5
  6response.write "<script language="javascript">"   
  7response.write "javascript:opener.location.reload(); "   
  8response.write "javasript:window.close();</script>" 
  9
 10** 36\. JS  ** ** 事件  ** **
 11
 12**
 13
 14事件  /  描述 
 15
 16onblur  事件  发生在窗口失去焦点的时候。    
 17onchange  事件  发生在文本输入区的内容被更改,然后焦点从文本输入区移走之后。    
 18onclick  事件  发生在对象被单击的时候。    
 19onerror  事件  发生在错误发生的时候。    
 20onfocus  事件  发生在窗口得到焦点的时候。    
 21onload  事件  发生在文档全部下载完毕的时候。    
 22onmousedown  事件  发生在用户把鼠标放在对象上按下鼠标键的时候。参考  onmouseup  事件。    
 23onmouseout  事件  发生在鼠标离开对象的时候。参考  onmouseover  事件。    
 24onmouseover  事件  发生在鼠标进入对象范围的时候。    
 25onmouseup  事件  发生在用户把鼠标放在对象上鼠标键被按下的情况下,放开鼠标键的时候。    
 26onreset  事件  发生在表单的“重置”按钮被单击(按下并放开)的时候。    
 27onresize  事件  发生在窗口被调整大小的时候。    
 28onsubmit  事件  发生在表单的“提交”按钮被单击(按下并放开)的时候。    
 29onunload  事件  发生在用户退出文档(或者关闭窗口,或者到另一个页面去)的时候。    
 30onSelect  当  Text  或  Textarea  对象中的文字被加亮后,引发该事件。    
 31onFocus  当用户单击  Text  或  textarea  以及  select  对象时,产生该事件。    
 32onBlur  当  text  对象或  textarea  对象以及  select  对象不再拥有焦点、而退到后台时,引发该文件  .   
 33onDragDrog  拖放时发生    
 34onLoseCapture    
 35onDblClick  鼠标双击事件    
 36onKeyPress  当键盘上的某个键被按下并且释放时触发的事件  .[  注意  :  页面内必须有被聚焦的对象  ]   
 37onKeyDown  当键盘上某个按键被按下时触发的事件  [  注意  :  页面内必须有被聚焦的对象  ]   
 38onKeyUp  当键盘上某个按键被按放开时触发的事件  [  注意  :  页面内必须有被聚焦的对象  ]   
 39onAbort  图片在下载时被用户中断    
 40onBeforeUnload  当前页面的内容将要被改变时触发的事件    
 41onMove  浏览器的窗口被移动时触发的事件 
 42
 43** 37\.  ** ** 自动最大化  ** **
 44
 45**
 46
 47function window_onload()   
 48{   
 49window.moveTo(-2,-2);   
 50window.resizeTo(screen.availWidth, screen.availHeight);   
 51} 
 52
 53<body onload="window_onload()">
 54
 55** 38\.  ** ** 几个  ** ** SQL  ** ** 技巧  ** **
 56
 57**
 58
 59** SELECT Area,Territory,username,sum(dealqty) DealQty,count(Projectnum) ProjectQty,sum(TotalAmount) TotalAmountQty,sum(TotalPowerRT) TotalPowerRT  FROM VW_PreviewTerritory  where  username = '  ** ** 段龙义  ** ** ' group by area,Territory,username   
 60** ** 只要把不需要统计的东西分组就可以了。  ** **
 61
 62**
 63
 64** select area,count(projectnum) TotalProjectQty,sum(DealQty) TotalDealQty,sum(TotalAmount) TotalAmountQty,sum(TotalPowerRT) TotalPowerRTQty from vw_previewProject where username = 'admin' group by area   
 65** ** 这个也是一样,记住:  ** ** count()  ** ** 只是计数,不管这个字段值是多少。  ** ** sum()  ** ** 是求和,把所有加在一起。  ** **
 66
 67**
 68
 69** 39\. Eval  ** ** 用法  ** **
 70
 71**
 72
 73** eval("ProducingArea"+i+".style.display = 'none' ;");   
 74** ** 单引号不影响  ** **   
 75eval("if((window.form1.ProductBaseType"+i+".value!='' &amp;&amp; window.form1.ProductBaseType"+(i+1)+".value =='')==true);");   
 76//  ** ** 错误!  ** **   
 77if(eval("window.form1.ProductBaseType"+i+".value!='' &amp;&amp; window.form1.ProductBaseType"+(i+1)+".value ==''")==true)   
 78//  ** ** 以后记得凡是有  ** ** if  ** ** 判断的,把  ** ** eval("")  ** ** 写在里面,就比较好!  ** **   
 79if(confirm(eval("'  ** ** 确信要在  ** ** '+window.form1.ProductBaseType"+(i)+".value+'  ** ** 后添加子类?  ** ** '"))) 
 80
 81**
 82
 83**
 84
 85**
 86
 87** 40\.  ** ** 窗口关闭之前  ** **
 88
 89**
 90
 91** function window_onbeforeunload(Projectnum)   
 92{   
 93if (event.clientX &gt; document.body.clientWidth &amp;&amp; event.clientY &lt; 0 )   
 94{   
 95var oXMLHTTP = new ActiveXObject("Microsoft.XMLHTTP");   
 96oXMLHTTP.open("POST","CheckProjectDeal.asp?Projectnum="+Projectnum,false);   
 97oXMLHTTP.send();   
 98Str=unescape(oXMLHTTP.responseText);   
 99if (unescape(oXMLHTTP.responseText)!="YES")   
100{   
101window.event.returnValue="  ** ** 项目至少需要一个销售机会!  ** ** ";   
102}   
103}   
104} 
105
106**
107
108** 41\.  ** ** 标准表格  ** **
109
110**
111
112*************** 
113
114*  这个是标题 
115
116*************** 
117
118<table border="0" cellpadding="0" cellspacing="0" width="100%">
119<tr>
120<td align="left" class="title" nowrap="">   

response.write Application("LProductManage"&amp;session("LanguageId"))

  1
  2</td>
  3</tr>
  4</table>
  5
  6*************** 
  7
  8*  这个是横线 
  9
 10*************** 
 11
 12<table border="0" cellpadding="0" cellspacing="0" width="100%">
 13<tbody>
 14<tr>
 15<td>
 16</td>
 17</tr>
 18<tr class="linecolor">
 19<td height="2"></td>
 20</tr>
 21<tr>
 22<td align="left" class="tdcolor" height="15"> </td>
 23</tr>
 24</tbody>
 25</table>
 26
 27*************** 
 28
 29*  这个是表格 
 30
 31*************** 
 32
 33<table bgcolor="#d0d090" border="0" cellpadding="0" cellspacing="1" width="100%">
 34<tbody>
 35<th align="middle" class="light2"><b>```
 36=application("Lstatus"&amp;amp;session("languageid"))
 37```</b></th>
 38<th align="middle" class="light2"><b>```
 39=application("LSaleStage"&amp;amp;session("languageid"))
 40```</b></th>
 41<tr bgcolor="white">
 42<td align="middle"> </td>
 43<td align="middle"> </td>
 44</tr>
 45</tbody>
 46</table>
 47
 48边框  \  填充  = 0 
 49
 50间隔  =  1 
 51
 52底色  = #d0d090 
 53
 54** 42\.  ** ** 这也行  ** **
 55
 56**
 57
 58for i=2 to num 
 59
 60BaseTypeAllPArr = request("BaseType"&amp;i&amp;"P"&amp;jLoop)&amp;":"&amp;BaseTypeAllPArr 
 61
 62response.Write "  OOOO  "&amp;request("BaseType"&amp;i&amp;"P"&amp;jLoop)&amp;"  OOOO  <br/>"   
 63next 
 64
 65** 43\.  ** ** 标准注释头  ** **
 66
 67**
 68
 69'' ****************************************************************** 
 70
 71''  文件名  : 
 72
 73'' Copyright (c) 2001-2005  ××信息技术公司软件部 
 74
 75''  功能描述  :  产品编辑 
 76
 77''  参数 
 78
 79''  牵涉数据表,视图,存储过程:自定义函数  dbo.GetSubTreeinfo 
 80
 81''  包含的文件  : 
 82
 83''  调用的公用函数,类,方法 
 84
 85''  创建人  :Kokey YU 
 86
 87''  日 期  :  2005-8-9 
 88
 89''  修改人  : 
 90
 91''  日 期  : 
 92
 93''  修改说明  : 
 94
 95''  版 本  : 
 96
 97'' ******************************************************************/ 
 98
 99** 44\. title  ** ** 换行  ** **
100
101**
102
103** <a href="javascript:;" title="  ** ** 这是一行  ** ** 
104  ** ** 这是另一行!  ** ** "> ** ** 把鼠标放上来  ** ** </a>
105
106**</body></form>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus