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?