<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="check.asp"-->
<!--#include file="../dbconn/conn.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新增模板</title>
<link href="../style/css.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.ToolBarGegin { border-right-width: thin;
border-right-style: ridge;
height: 100%;
width: 3px;
border-right-color: #FFFFFF;
}
-->
</style></head><body>
<form action="add_templets_end.asp" name="edit" method="post" onsubmit="return xxg()">
<table width="100%"  border="0" cellpadding="0" cellspacing="0" class="ButtonList">
  <tr>
    <td height="30" align="right"><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="ButtonList">
      <tr>
        <td width="3%" height="30" align="right"><input name="" type="image" src="../Images/save.gif" border=0></td>
        <td width="7%" align="right">模板名称</td>
        <td width="18%" align="center"><input type="text" name="title" style="font-size:12px"></td>
        <td width="15%" height="30"><select style="font-size:12px" onChange="InsertStr(this.value)" title="插入表单代码" name="select">
          <option  value="" selected>选择要插入的标签</option>
  <%CALL CONN_OPEN()
  LABELSQL = "SELECT LATE_CNAME,LATE_ENAME FROM LATE_TABLE"
  SET LABELRS = SERVER.CREATEOBJECT("ADODB.RECORDSET")
  LABELRS.OPEN LABELSQL,CONN,1,1
  DO WHILE NOT LABELRS.EOF
     RESPONSE.WRITE "<OPTION VALUE={BT165_"&LABELRS("LATE_CNAME")&"}>"&LABELRS("LATE_CNAME")&"</OPTION>"
     LABELRS.MOVENEXT
  LOOP%>
        </select></td>
        <td width="5%" align="center">&nbsp;</td>
        <td width="52%">&nbsp;</td>
      </tr>
    </table></td>
    </tr>
  <tr>
    <td height="582" valign="top"><textarea onChange="SetEditFlag();" id="EditArea" name="textarea" style="width:99%;height:560px;font-size:12px"></textarea></td>
    </tr>
</table>
</form>
</body>
</html>
<form id="TempForm" name="TempForm"></form>
<script language="JavaScript">
var AlreadyEdit=false;
var bInitialized = false;
function xxg(){
  if(document.edit.title.value==""){
     alert('请输入模板标题,否则为不可识别的模板!');
 document.edit.title.focus();
 return false;
  }
  return true;
}
function SetEditAreaHeight()
{
var BodyHeight=document.body.clientHeight;
//var EditAreaHeight=BodyHeight-document.all.ToolBar.height;
//document.all.EditArea.style.height=EditAreaHeight;
}
SetEditAreaHeight();
window.onresize=SetEditAreaHeight;
//window.onunload=PromptSave;
function document.onreadystatechange()
{
if (document.readyState!="complete") return;
if (bInitialized) return;
bInitialized = true;
var i,j,s,curr;
for (i=0; i<document.body.all.length;i++)
{
curr=document.body.all[i];
if (curr.className == "ToolBtn") InitBtn(curr);
}
}
function SetEditFlag()
{
AlreadyEdit=true;
}
function InsertStr(Str)
{
//var str=document.edit.textarea.value;
//alert(str);
document.edit.EditArea.focus();
var RangeObj=document.selection.createRange();
RangeObj.text=Str;
}
function InsertForm()
{
var Str='<form name="" action="" method="post">\n\n</form>';
InsertStr(Str);
}
function InitBtn(btn) 
{
btn.onmouseover = BtnMouseOver;
btn.onmouseout = BtnMouseOut;
btn.onmousedown = BtnMouseDown;
btn.onmouseup = BtnMouseOut;
btn.ondragstart = YCancelEvent;
btn.onselectstart = YCancelEvent;
btn.onselect = YCancelEvent;
btn.disabled=false;
return true;
}function BtnMouseOver() 
{
var image = event.srcElement;
image.className = "ToolBtnMouseOver";
event.cancelBubble = true;
}function BtnMouseOut() 
{
var image = event.srcElement;
image.className = "ToolBtn";
event.cancelBubble = true;
}function BtnMouseDown() 
{
var image = event.srcElement;
image.className = "ToolBtnMouseDown";
event.cancelBubble = true;
event.returnValue=false;
return false;
}
function YCancelEvent() 
{
event.returnValue=false;
event.cancelBubble=true;
return false;
}
</script>

解决方案 »

  1.   

    能否请宁录大侠,稍微改写下,弄个纯html和js的demo?
    其它大侠帮忙,同样欢迎
      

  2.   

    我有一个想法:
    取得鼠标所在处,字符串的位置,记录下来 。比如 
    “12367”,鼠标在36之间 ,我记录一个4(鼠标位置),
    然后把新的到的东西,插进去 
    新的字符串=left子串+刚刚得到的字符串+right子串
    这样一来,问题就转化为,得到鼠标所在处字符相对于整串的位置。
      

  3.   

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新增模板</title>
    <link href="../style/css.css" rel="stylesheet" type="text/css">
    <style type="text/css">
    <!--
    body,td,th {
    font-size: 12px;
    }
    body {
    margin-left: 0px;
    margin-top: 0px;
    margin-right: 0px;
    margin-bottom: 0px;
    }
    .ToolBarGegin {border-right-width: thin;
    border-right-style: ridge;
    height: 100%;
    width: 3px;
    border-right-color: #FFFFFF;
    }
    -->
    </style></head><body>
    <form action="add_templets_end.asp" name="edit" method="post" onsubmit="return xxg()">
    <table width="100%"  border="0" cellpadding="0" cellspacing="0" class="ButtonList">
      <tr>
        <td height="30" align="right"><table width="100%"  border="0" cellpadding="0" cellspacing="0" class="ButtonList">
          <tr>
            <td height="30" align="left"><select style="font-size:12px" onChange="InsertStr(this.value)" title="插入表单代码" name="select">
                <option value="0" selected>选择要插入的标签</option>
                <option value="1">111111</option>
                <option value="3">22222</option>
            </select></td>
            </tr>
        </table></td>
        </tr>
      <tr>
        <td height="582" valign="top"><textarea onChange="SetEditFlag();" id="EditArea" name="textarea" style="width:99%;height:560px;font-size:12px"></textarea></td>
        </tr>
    </table>
    </form>
    </body>
    </html>
    <form id="TempForm" name="TempForm"></form>
    <script language="JavaScript">
    var AlreadyEdit=false;
    var bInitialized = false;
    function xxg(){
      if(document.edit.title.value==""){
         alert('请输入模板标题,否则为不可识别的模板!');
     document.edit.title.focus();
     return false;
      }
      return true;
    }
    function SetEditAreaHeight()
    {
    var BodyHeight=document.body.clientHeight;
    //var EditAreaHeight=BodyHeight-document.all.ToolBar.height;
    //document.all.EditArea.style.height=EditAreaHeight;
    }
    SetEditAreaHeight();
    window.onresize=SetEditAreaHeight;
    //window.onunload=PromptSave;
    function document.onreadystatechange()
    {
    if (document.readyState!="complete") return;
    if (bInitialized) return;
    bInitialized = true;
    var i,j,s,curr;
    for (i=0; i<document.body.all.length;i++)
    {
    curr=document.body.all[i];
    if (curr.className == "ToolBtn") InitBtn(curr);
    }
    }
    function SetEditFlag()
    {
    AlreadyEdit=true;
    }
    function InsertStr(Str)
    {
    //var str=document.edit.textarea.value;
    //alert(str);
    document.edit.EditArea.focus();
    var RangeObj=document.selection.createRange();
    RangeObj.text=Str;
    }
    function InsertForm()
    {
    var Str='<form name="" action="" method="post">\n\n</form>';
    InsertStr(Str);
    }
    function InitBtn(btn) 
    {
    btn.onmouseover = BtnMouseOver;
    btn.onmouseout = BtnMouseOut;
    btn.onmousedown = BtnMouseDown;
    btn.onmouseup = BtnMouseOut;
    btn.ondragstart = YCancelEvent;
    btn.onselectstart = YCancelEvent;
    btn.onselect = YCancelEvent;
    btn.disabled=false;
    return true;
    }function BtnMouseOver() 
    {
    var image = event.srcElement;
    image.className = "ToolBtnMouseOver";
    event.cancelBubble = true;
    }function BtnMouseOut() 
    {
    var image = event.srcElement;
    image.className = "ToolBtn";
    event.cancelBubble = true;
    }function BtnMouseDown() 
    {
    var image = event.srcElement;
    image.className = "ToolBtnMouseDown";
    event.cancelBubble = true;
    event.returnValue=false;
    return false;
    }
    function YCancelEvent() 
    {
    event.returnValue=false;
    event.cancelBubble=true;
    return false;
    }
    </script>
      

  4.   

    这个就完全是JS和HTML组成的了,如果不想什么,还可以删除一些,自己看看
      

  5.   

    caq9966太强了吧....加入我们的LF工作组吧
      

  6.   

    有用的只有一段而已,
    <select onChange="InsertStr(this.value)">
    <option value="0" selected>选择要插入的标签</option>
    <option value="1">111111</option>
    <option value="3">22222</option>
    </select>
    <br/>
    <textarea id="ice"></textarea>
    <script language="JavaScript">
    function InsertStr(Str)
    {
    document.getElementById("ice").focus();
    var RangeObj=document.selection.createRange();
    RangeObj.text=Str;
    }
    </script>