• 首页
  • 移动开发
  • Web前端
  • 企业架构
  • 编程语言
  • 互联网
  • 开源软件
  • 操作系统
  • 数据库
  • 研发管理
  • 行业应用
  • 非技术
首页编程语言

情感:帮忙啊怎么实现删除 源码附上

2012-01-13 15:52:21 作者:sandy 来源: 浏览次数:0

本帖最后由 仙度瑞拉 于 2011-11-18 06:58 编辑



现在只是实现了隐藏,但添加新标签后还是没有删除。请问要怎么改才能实现删除啊……我把写的源码贴上了



输入设定为“/jpg *** ”,第二个空格输入后,自动将***转换成标签在页面输出。标签可删除。



    <html>

    <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <title>搜索</title>



    <style type="text/css">

    div{height: 2em;}

    div span{margin: 2px;

    background: #ffc;

    font-size: 12px;

    padding: 2px;

    border-width: 0 0 0 0;

    border-style: solid;

    border-color: #999;

    cursor: pointer;

    color: #000;}

    </style>



    </head>

    <body>





    <script type="text/javascript" language="javascript">

    //标签变量初始化

    var tags = new Array();

    var html = '';

    var flag=0;



    var label = new Array();



    function gbcount(message)

    {

    var max;

    max=30;

    var a1=document.getElementById("quotation");

    if (message.value.length > max) {

    message.value = message.value.substring(0,max);



    alert("内容不允许超过30个字!");// 达到限制数,弹出警告

    }

    else {

    var showout=document.getElementById("showout");

    showout.innerHTML=a1.value;



    }

    }



    function checkInput(e){



    e = (e)?e: window.event;



    var value = document.getElementById("quotation").value;

    if(value.length ==0){

    flag++;

    html='';

    //alert(flag)

    }



    if(e.keyCode && e.keyCode==32){



    var temp = value.split(" ");

    if(temp[0]!="/jpg") alert("输入格式错误!")



    if(temp[0]=="/jpg"&&temp.length>=2){







    tags[flag]=new Array();

    tags[flag][0]=temp[1]+" ×";

    //alert(tags[flag][0])

    }



    label[flag]="<span id=\"show2\" onClick=\"hide(this)\">"+tags[flag][0]+"</span> ";



    //alert(flag)

    for(var i=0;i<=flag;i++)

    {

    if(label[i]) {html +=label[i];}

    }





    // html +="<span id=\"show2\" onClick=\"hide(this)\">"+tags[flag][0]+"</span> ";

    document.getElementById("out").innerHTML = html;

    }



    }







    hide = function(obj)

    { //alert("ok")

    //alert(n)

    obj.style.display="none";

    //label[n]="";

    //for(var i=0;;i++)

    //alert(label[i])

    }





    </script>

    <div style=" margin:auto; width:400px;">

    <form id="form1">

    <div id="show"></div>

    <div id="src">

    <div style="float:left" id="out">

    <!-- 一个标签对应一个 -->

    </div>

    <input name="quotation" onkeyup=gbcount(this.form.quotation); onkeydown="checkInput()"; cols="80" rows="1" wrap="VIRTUAL" id="quotation" />

    <div id="showout"></div>

    </div>



    </form>

    </div>

    </body>

    </html>
复制代码运行代码另存代码



关键词:源码

广告商赞助区

广告商赞助区

CopyRight 2009-2015


B2-20040053 Powered by Sh-Links.Com