Little things at work

Source: Internet
Author: User
Today, I have nothing to think about. I 've written a lot of JS recently. I have a whimsy. I remember someone asked me a question when I was looking for a job last year: Write a paragraph. Code Clear all the text boxes on the page. At that time, I remembered to use the code on the server. The results were also achieved and I had never done it before. But I was very impressed when I made it that day, today, I want to know if I can use js to write it. I will fix it in three minutes: Javaspt PT Function
1 < Script Language = " Javascript " Type = " Text/JavaScript " >
2 Function Clearalltext ()
3 {
4 VaR Arr = Document. All;
5 For (I = 0 ; I < Arr. length; I ++ )
6 {
7 If (ARR [I]. Type = " Text " )
8 {
9Document. getelementbyid (ARR [I]. ID). Value="";
10}
11 }
12 Return   False ;
13 }
14 </ Script >

then at: onclientclick = "javascript: return clearalltext (); "/>
in this way, all the text boxes are quietly cleared without refreshing the new page. The text boxes are accidentally cleared;
There is also a small trick, which was tried two days ago: many methods use a label Label when prompting the customer for friendly information, when you assign a value to it, the system prompts "What is wrong with your input". However, most people usually use the visible = true/false method to control the friendly information when clicking the button, or clear the values in the label and you will not be able to see the prompt information, but this is not a good method. I want to use this better method: the label is empty during initialization, and then its enableviewstate = "False", this is good, you can do a lot less, you know the role of viewstate, as a hidden domain will only increase the burden on the server side, may generate some unnecessary code, so you don't need to use it if you don't have to. Isn't it a two-pronged process?

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.