• 复选框和下拉框js如何操作合格复选框或下拉框中元素


    <div style=" 510px; border: 1px grey solid; border-right: 1px gray; padding-top: 1px;" id="heddendiv">

    <div>
    <ul id="addressul" class="ul_s">
    </ul>
    <div style="color: #ccc; position: absolute;padding-top:1px;padding-left:5px" id="textDiv1" onclick="document.getElementById('serach').focus();">

    </div>
    <input type="text" name="serach" id="serach" class="inputs" style=" 500px;padding:2px;display:inline;" onblur="if(this.value==''&&document.getElementById('addressul').childNodes.length==0)document.getElementById('textDiv1').style.display='inline';" onfocus="document.getElementById('textDiv1').style.display='none'">
    </div></div>

    js:
    //添加选中的关键字
    function addLi(name,id,type,typeName){

    var addUl =jQuery("#addressul");
    var addUlLi =jQuery("#addressul li");

    if(addUl && addUlLi.length<5){
    superType = type;
    var textWidth = jQuery("#serach").css("width");

    if(name.length>15){
    name=name.substring(0,15);
    }
    for(i=0;i<addUlLi.length;i++){
    var tmpLi = addUlLi.eq(i);

    if(tmpLi.attr("id")=="li_"+id){
    alert(name+" 已选择,请勿重复选择!");
    return;
    }
    }
    addUl.append("<li id="li_"+id+"" name="+name+" value="+id+">"+name+"<img src="/images/section/tp.gif"></li>");

    jQuery("#li_"+id+" img").unbind().click(function(){removeLI("li_"+id)});
    var liWidth = jQuery("#li_"+id).css("width");
    var lastWidth = parseInt(textWidth)-parseInt(liWidth)-4;
    jQuery("#serach").css("width",lastWidth);
    jQuery("#serach").focus();
    }else{
    alert("接收人最多不得超过5人!");
    jQuery("#serach").focus();
    }
    }
    后台:
    String otherPerson = data.getRequest().getParameter("otherPerson");//myy

    if(otherPerson!=null){
    String others[]=otherPerson.split(",");
    for(int i=0;i<others.length;i++){
    if(others[i]!=null&&!"".equals(others[i])){
    tousers.add(others[i]);
    }
    }
    service.sendMsg(msg, tousers.toArray(new String[0]));



    }






  • 相关阅读:
    Session的使用与管理
    CSS控制文字,超出部分显示省略号
    MP4 文件前端获取视频封面
    prefetch预加载功能使用
    react-学习之路-react-router-解决问题记录
    如何将一个div盒子水平垂直都居中?
    window下查看端口号,并删除对应进程
    判断js 验证字符串里面有没有包含汉字:
    vue 现有的$变量 以及如何添加全局变量
    与人言
  • 原文地址:https://www.cnblogs.com/mayay/p/6920319.html
Copyright © 2020-2023  润新知