ASP development skills highlights 4

Source: Internet
Author: User
Function ConfirmDel ()

{
If (confirm ("are you sure you want to delete it? Once deleted, it cannot be restored! "))

Return true;
Else
Return false;
}
<Form name = "del" method = "Post" action = "Del. asp" onsubmit = "return ConfirmDel ();">

I use one.

Function ConfirmReset ()

{
If (confirm ("are you sure you want to cancel the operation? Once canceled, the operation cannot be restored! "))

Window. form1.reset ();
// Return true;
}
<A href = "javascript: ConfirmReset ();"> </a>

32. indexOf () Usage

<String object>. indexOf (<another string object> [, <start position>]);

This method finds the <another string object> from the <String object> (if the <start position> is given, the previous position is ignored). If it is found, its position is returned, if no value is found, "-1" is returned ". All "positions" start from scratch.

Eg. Str. indexOf ("AP")>-1 indicates that the "AP" string exists in str.

33. Generate the serial number

<%
If request. form ("Modf") <> "" then
Dim rs
Dim SQL
Dim BugID
Dim today
Today = date ()

Toyear = year (today)

Toyear = toyear * 10000
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> = 0 then
Serialnum = OldSerialnum + 1
End if
End if
BugID = "ES" & request ("ProductVersion") & Serialnum

34. Return key

Function getdata (what, whatid)

{
If (event. keyCode = 13)

......
<Input name = "SerialNum <% = I %>" type = "text" onKeyDown = "getdata (window. form1.SerialNum <% = I %>. value, <% = I %>) ">

35. Refresh the parent page before closing the window

Response. write "<script language = javascript>"
Response. write "javascript: opener. location. reload ();"
Response. write "Fig: window. close (); </script>"

36. JS events

Event/Description
The onblur event occurs when the window loses focus.

The onchange event occurs when the content in the text input area is changed, and the focus is removed from the text input area.

The onclick event occurs when the object is clicked.

Onerror occurs when an error occurs.

The onfocus event occurs when the window gets the focus.

The onload event occurs when all documents are downloaded.

The onmousedown event occurs when the user places the mouse on the object and presses the mouse key. Refer to the onmouseup event.

The onmouseout event occurs when the mouse leaves the object. Refer to the onmouseover event.

The onmouseover event occurs when the mouse enters the object range.

The onmouseup event occurs when the user places the mouse on the object and the mouse key is pressed.

The onreset event occurs when the "reset" button of the form is clicked (pressed and released.

The onresize event occurs when the window is adjusted.

The onsubmit event occurs when the "Submit" button of the form is clicked (pressed and released.

The onunload Event occurs when the user exits the document (or closes the window, or goes to another page.

OnSelect this event is triggered when the Text in the Text or Textarea object is highlighted.

OnFocus this event is generated when you click Text, textarea, and select objects.

OnBlur triggers this file when the text object, textarea object, and select object no longer have focus and return to the background.
OnDragDrog dragging
OnLoseCapture
OnDblClick double-click event
OnKeyPress events triggered when a key on the keyboard is pressed and released. [Note: the page must contain focused objects]
OnKeyDown events triggered when a key on the keyboard is pressed [NOTE: The page must contain focused objects]
OnKeyUp events triggered when a button on the keyboard is pressed and opened [NOTE: The page must contain focused objects]
The onAbort image is interrupted by the user during download.
OnBeforeUnload event triggered when the content of the current page is about to be changed
Event triggered when the window of the onMove browser is moved

37. Automatic Maximization

Function window_onload ()

{
Window. moveTo (-2,-2 );
Window. resizeTo (screen. availWidth, screen. availHeight );
}
<Body onload = "window_onload ()">

38. Several SQL skills

SELECT Area, Territory, username, sum (dealqty) DealQty, count (Projectnum) ProjectQty, sum (TotalAmount) TotalAmountQty, sum (TotalPowerRT) totalPowerRT FROM VW_PreviewTerritory where username = 'duan longy' group by area, Territory, username
You just need to group the items that do not need to be counted.

Select area, count (projectnum) TotalProjectQty, sum (DealQty) TotalDealQty, sum (TotalAmount) amount, sum (TotalPowerRT) TotalPowerRTQty from vw_previewProject where username = 'admin' group by area
The same is true. Remember: count () is only a count, regardless of the value of this field. Sum () is the sum that adds all together.

39. Eval usage

Eval ("ProducingArea" + I + ". style. display = 'none ';");
Single quotes are not affected
Eval ("if (window. form1.ProductBaseType" + I + ". value! = ''& Window. form1.ProductBaseType" + (I + 1) + ". value ='') = true );");
// Error!

If (eval ("window. form1.ProductBaseType" + I + ". value! = ''& Window. form1.ProductBaseType" + (I + 1) + ". value ='' ") = true)

// Remember to write eval ("") in case of if judgment!

If (confirm (eval ("'Are you sure you want to add a subclass after' + window. form1.ProductBaseType" + (I) + ". value +? '")))

40. Before the window is closed

Function window_onbeforeunload (Projectnum)

{
If (event. clientX> document. body. clientWidth & event. clientY <0)

{
Var oXMLHTTP = new ActiveXObject ("Microsoft. XMLHTTP ");
OXMLHTTP. open ("POST", "CheckProjectDeal. asp? Projectnum = "+ Projectnum, false );
OXMLHTTP. send ();
Str = unescape (oXMLHTTP. responseText );
If (unescape (oXMLHTTP. responseText )! = "YES ")

{
Window. event. returnValue = "the project requires at least one sales lead! ";
}
}
}

41. Standard Form

***************
* This is the title.
***************
<Table cellspacing = 0 cellpadding = 0 width = "100%" border = 0>
<Tr>
<Td class = title nowrap align = left>
<% Response. write Application ("LProductManage" & session ("LanguageId") %>
</Td>
</Tr>
</Table>
***************
* This is a horizontal line.
***************
<Table cellspacing = 0 cellpadding = 0 width = "100%" border = 0>
<Tbody>
<Tr>
<Td>
</Td>
</Tr>
<Tr class = "linecolor">
<Td height = "2"> </td>
</Tr>
<Tr>
<Td class = "tdcolor" align = left height = 15> & nbsp; </td>
</Tr>
</Tbody>
</Table>
***************
* This is a table.
***************
<Table border = 0 cellpadding = 0 cellspacing = 1 width = 100% bgcolor = "# d0d090">
<Tbody>
<Th align = "center" class = light2> <B> <% = application ("Lstatus" & session ("languageid") %> </B> </th>
<Th align = "center" class = light2> <B> <% = application ("LSaleStage" & session ("languageid") %> </B> </th>
<Tr bgColor = "white">
<Td align = "center"> & nbsp; </td>
<Td align = "center"> & nbsp; </td>
</Tr>
</Tbody>
</Table>
Border \ fill = 0
Interval = 1
Background color = # d0d090

42. This is fine.

For I = 2 to num
BaseTypeAllPArr = request ("BaseType" & I & "P" & jLoop) & ":" & BaseTypeAllPArr
Response. Write "OOOO" & request ("BaseType" & I & "P" & jLoop) & "OOOO <br>"
Next

43. Standard comment Header

''************************************** **********************
''File Name:

''Copyright (c) 2001-2005 ×× information technology company software department
''Function Description: Product editing
''Parameter
''Involves data tables, views, and stored procedures: custom function dbo. GetSubTreeinfo
''Contained files:

''Called public functions, classes, and methods
''Created by: Kokey YU
'''Date:
''Modifier:

'''Date:

''Modification description:

''Version:

''************************************** *********/
44. title line feed

<A href = "javascript:;" title = "this is a line & #13 This is another line! ">

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.