Js implements text box effect with automatic prompts

WBOY
Release: 2016-07-25 09:12:45
Original
1221 people have browsed it

Share the js implementation code for two automatic prompt text box effects.

Example 1, directly write AJAX implementation. Client:

  1. Ajax text box for automatic prompting_bbs.it-home.org
  2. Color:
  3. < /html>
  4. Copy code
  5. 服务器端(9-10.aspx ):

    1. <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
    2. <%@ Import Namespace="System.Data" %>
    3. <%
    4. Response.CacheControl = "no-cache";
    5. Response.AddHeader("Pragma","no-cache");
    6. string sInput = Request["sColor"].Trim();
    7. if(sInput.Length == 0)
    8. return;
    9. string sResult = "";
    10. string[] aColors = new string[]{"aliceblue","antiquewith","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brass",
    11. "bronze","brown","burlywood","cadetblue","chartreuse","chocolate","copper","coral","cornfloewrblue","cornsilk","cyan",
    12. "darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkhaki","darkmagenta","darkolivegreen","darkorchid",
    13. "darkorenge","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink",
    14. "deepskyblue","dimgray","dodgerblue","feldspar","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","gold","goldenrod",
    15. "golenrod","gostwhite","gray","green","greenyellow","honeydew","hotpink","indianred","inen","ivory","khaki","lavender",
    16. "lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgodenrod","lightgodenrodyellow","lightgray",
    17. "lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslateblue","lightslategray","lightsteelblue","lightyellow",
    18. "lime","limegreen","magenta","magenta","maroom","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurpul",
    19. "mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream",
    20. "mistyrose","moccasin","navajowhite","navy","navyblue","oldlace","olivedrab","orange","orchid","orengered","palegodenrod",
    21. "palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","quartz","red",
    22. "rosybrown","royalblue","saddlebrown","salmon","sandybrown","scarlet","seagreen","seashell","sienna","silver","skyblue","slategray",
    23. "snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","violetred","wheat","whitesmoke","yellow","yellowgreen"};
    24. for(int i=0;iif(aColors[i].IndexOf(sInput) == 0)
    25. sResult += aColors[i] + ",";
    26. }
    27. if(sResult.Length>0) //如果有匹配项
    28. sResult = sResult.Substring(0,sResult.Length-1); //去掉最后的“,”号
    29. Response.Write(sResult);
    30. %>
    复制代码

    Example 2, implemented using jQuery. Client:

    1. jQuery implements automatic prompt text box
    2. Color:
    3. Copy code

      服务器端(14-10.aspx ):

      1. <%@ Page Language="C#" ContentType="text/html" ResponseEncoding="gb2312" %>
      2. <%@ Import Namespace="System.Data" %>
      3. <%
      4. Response.CacheControl = "no-cache";
      5. Response.AddHeader("Pragma","no-cache");
      6. string sInput = Request["sColor"].Trim();
      7. if(sInput.Length == 0)
      8. return;
      9. string sResult = "";
      10. string[] aColors = new string[]{"aliceblue","antiquewith","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brass","bronze",
      11. "brown","burlywood","cadetblue","chartreuse","chocolate","copper","coral","cornfloewrblue","cornsilk","cyan","darkblue","darkcyan",
      12. "darkgoldenrod","darkgray","darkgreen","darkhaki","darkmagenta","darkolivegreen","darkorchid","darkorenge","darkred","darksalmon",
      13. "darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue",
      14. "feldspar","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","gold","goldenrod","golenrod","gostwhite","gray","green",
      15. "greenyellow","honeydew","hotpink","indianred","inen","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon",
      16. "lightblue","lightcoral","lightcyan","lightgodenrod","lightgodenrodyellow","lightgray","lightgreen","lightpink","lightsalmon",
      17. "lightseagreen","lightskyblue","lightslateblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","magenta",
      18. "magenta","maroom","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurpul","mediumseagreen",
      19. "mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose",
      20. "moccasin","navajowhite","navy","navyblue","oldlace","olivedrab","orange","orchid","orengered","palegodenrod","palegreen",
      21. "paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","quartz","red","rosybrown",
      22. "royalblue","saddlebrown","salmon","sandybrown","scarlet","seagreen","seashell","sienna","silver","skyblue","slategray","snow",
      23. "springgreen","steelblue","tan","thistle","tomato","turquoise","violet","violetred","wheat","whitesmoke","yellow","yellowgreen"};
      24. for(int i=0;iif(aColors[i].IndexOf(sInput) == 0)
      25. sResult += aColors[i] + ",";
      26. }
      27. if(sResult.Length>0) //如果有匹配项
      28. sResult = sResult.Substring(0,sResult.Length-1); //去掉最后的“,”号
      29. Response.Write(sResult);
      30. %>
      复制代码


      source:php.cn
      Statement of this Website
      The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
      Popular Tutorials
      More>
      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template