显示剩余可输入的数字

news/2024/7/5 1:07:06

一、引入css

 1 .clsShowInfoWindow {
 2     BORDER-RIGHT: #8AB3F4 3px solid;
 3     PADDING-RIGHT: 0em;
 4     BORDER-TOP: #8AB3F4 3px solid;
 5     PADDING-LEFT: 0em;
 6     FONT-SIZE: smaller;
 7     font-family:Verdana, Arial, Helvetica;
 8     font-size:12px;
 9     Z-INDEX: 101;
10     PADDING-BOTTOM: 0em;
11     BORDER-LEFT: #8AB3F4 3px solid;
12     WIDTH: 260px;
13     COLOR: #000000;
14     PADDING-TOP: 0em;
15     BORDER-BOTTOM: #8AB3F4 3px solid;
16     position:absolute;
17     BACKGROUND-COLOR: #CEE0EB;
18     table-layout:fixed;
19     word-break:break-all
20 }
21 table.tableBorderStyle{
22          BORDER-RIGHT: #ffffff 0px solid;
23          BORDER-TOP: #ffffff 0px solid;
24          BORDER-LEFT:#ffffff 0px;
25          BORDER-BOTTOM:#ffffff 0px;
26          margin:1;
27          text-align:center
28 }
29 td.tdBorderStyle{
30          BORDER-RIGHT: #666666 1px solid;
31          BORDER-TOP: #666666 1px solid;
32          BORDER-LEFT:#666666 1px solid;
33          BORDER-BOTTOM:#666666 1px solid;
34          text-align:center
35 }
36 .scrollStyle{
37          width:100%;
38             height:15px;
39             overflow:hidden;
40          vertical-align:middle;
41          text-align:left;
42          word-break:break-all;
43          word-wrap:break-word
44 }

二、引入js
 1 /*firefox*/function __firefox(){    HTMLElement.prototype.__defineGetter__("runtimeStyle", __element_style);    window.constructor.prototype.__defineGetter__("event", __window_event);    Event.prototype.__defineGetter__("srcElement", __event_srcElement);}function __element_style(){    return this.style;}function __window_event(){    return __window_event_constructor();}function __event_srcElement(){    return this.target;}function __window_event_constructor(){    if(document.all){        return window.event;    }    var _caller = __window_event_constructor.caller;    while(_caller!=null){        var _argument = _caller.arguments[0];        if(_argument){            var _temp = _argument.constructor;            if(_temp.toString().indexOf("Event")!=-1){                return _argument;            }        }        _caller = _caller.caller;    }    return null;}if(window.addEventListener){    __firefox();}/*end firefox*/ 
 2 
 3 function showInfoWithPanel(obj){
 4    try{
 5           //var e=event||window.event;
 6           var showInfoWindow=document.getElementById("showInfomation");
 7           showInfoWindow.className="clsShowInfoWindow";
 8           showInfoWindow.style.visibility="visible";
 9           var x=document.body.scrollLeft+event.clientX+10;
10           var y=event.clientY+document.body.scrollTop+10;//+document.documentElement.scrollTop;
11           showInfoWindow.style.left=x;
12           showInfoWindow.style.top=y;
13           showInfoWindow.innerHTML="";
14           showInfoWindow.innerHTML=obj.innerHTML;//+" clientY:"+y+" clientX:"+x;
15           obj.style.color="red";
16    }catch(e){alert("showInfoWithPanel:"+e.message);}
17 }
18 function hiddenInfoPanel(obj){
19       try{
20          var showInfoWindow=document.getElementById("showInfomation");
21          if(showInfoWindow || typeof(showInfoWindow)!='undefined'){
22           showInfoWindow.innerHTML="";
23           showInfoWindow.style.visibility="hidden";
24           }
25           obj.style.color="#000000";
26     }catch(e){alert("hiddenInfoPanel:"+e.message);}
27 }

三、使用在script中

 1   function checkchar(){
 2   
 3           if(document.Form2.stationRun.value.length>2500){
 4       
 5              alert("站点运行情况字数不能超过2500字");
 6              return;
 7           }
 8           if(document.Form2.devRun.value.length>2500){
 9       
10              alert("设备运行情况字数不能超过2500字");
11              return;
12           }
13           document.Form2.action="commonMsgAction_saveMsg.do";
14           loading();
15           document.Form2.submit();
16           alert(" 待办事宜保存成功!");
17   }
18   function addEnter(element){
19            document.getElementById(element).value = document.getElementById(element).value+"<br>";
20    
21   }
22   function checkTextAreaLen(){
23           var stationRun = new Bs_LimitedTextarea('stationRun', 2500); 
24         stationRun.infolineCssStyle = "font-family:arial; font-size:11px; color:gray;";
25         stationRun.draw();    
26       
27         var devRun = new Bs_LimitedTextarea('devRun', 2500); 
28         devRun.infolineCssStyle = "font-family:arial; font-size:11px; color:gray;";
29         devRun.draw();    
30   }
31   window.οnlοad=function(){
32         checkTextAreaLen();
33         
34   };


 

 在body中使用

<div id="showInfomation" style="visibility: hidden"></div>


使用

addEnter('stationRun')函数
1 <textarea name="stationRun" id="stationRun"   style="width: 500px; height: 160px; padding: 1;FONT-FAMILY: 宋体; FONT-SIZE: 9pt" οnkeydοwn="if(event.keyCode==13)addEnter('stationRun');"><s:property value="stationRun" escapeXml="false"/></textarea>

 

转载于:https://www.cnblogs.com/pi-qingwen/p/5110062.html


http://www.niftyadmin.cn/n/2251948.html

相关文章

飞机大战c语言设计报告,中南大学电信-C语言飞机大战实验报告.doc

中南大学电信-C语言飞机大战实验报告C语言课程设计报告题 目 C语言飞机大战学生姓名学 号指导教师学 院 信息科学与工程学院专业班级 电子信息工程2班完成时间程序框图按任意键进入游戏结束系统具体实现运用C语言编写系统&#xff0c;就是程序模块化设计&#xff0c;编写一个个…

c语言向二进制文件中写入0x00,C语言 :文件操作 -2

C语言获取文件大小&#xff1a;#define _CRT_SECURE_NO_WARNINGS //去掉安全检查#include#include#includechar path1[100] "C:\\Users\\whx\\Desktop\\test.txt"; //文本文件char path2[100] "C:\\Users\\whx\\Desktop\\SpaceSniffer.exe"; //二进制文件…

c语言差速小车算法,差速器在汽车上多方面应用研究.PDF

机械设计与制造 第3期&Manufacture 2010年3月MachineryDesign文章编号&#xff1a;100l一3997(2010)03删棚3差速器在汽车上的多方面应用研究祁炳楠张利鹏20fdifferentiaIinVehiCIeMuIti—appCatiOnQIBing—n粕1&#xff0c;zHANG“呻en92Schoolof and(1 AutomobileT瑚mspor…

linux学习历程(2)

2019独角兽企业重金招聘Python工程师标准>>> BIOS&#xff1a;主板自带的操作系统&#xff0c;用来对电脑的基本设备进行设置。虚拟机的boot启动会自动调整&#xff0c;真实机安装时&#xff0c;需要先切换到dvd或者是usb&#xff0c;然后安装完成后再切换到硬盘启动…

c语言已知数列F(n)当n=1时F(n)=5,C语言复习题

原标题&#xff1a;C语言复习题这个寒冷的季节因你的关注而变得温暖期末考试来临&#xff0c;同学们有好好复习吗&#xff1f;改错题Fun函数的功能是&#xff1a;根据形参n&#xff0c;计算s11/21/3…1/n的值。在主函数中输入一个正整数n&#xff0c;通过调用fun函数&#xff0…

nginx的基本配置和虚拟主机的配置

Nginx的基本配置Nginx的主配置文件是&#xff1a;nginx.confnginx.conf 主要组成如下&#xff1a;Nginx的虚拟主机配置什么是虚拟主机虚拟主机使用的是特殊的软硬件技术&#xff0c;它把一台运行在因特网上的服务器主机分成一台台“虚拟”的主机&#xff0c;每台虚拟主机都可以…

postgresql 源码客户端认证

--在使用pg中登陆数据库是第一步&#xff0c;其代码结构如下&#xff1a;--原始代码在如下文件中 src/backend/libpq/auth.c--其入口函数为ClientAuthentication&#xff0c;其接受一个Port结构体 void ClientAuthentication(Port *port) {--通过此函数解析客户的ip类型&#x…

MingW编译virt-viewer

在http://www.spice-space.org/download.html可以下载到windows版本的virt viewer virt-viewer-x86-0.5.7.msi和virt-viewer-x64-0.5.7.msi是使用MingW编译出来的&#xff0c;源码就是使用virt-viewer-0.5.7.tar.gz 如果需要定制virt viewer&#xff0c;就需要从源码编译出可执…