2 jiaoxiaobin50 jiaoxiaobin50 于 2016.03.15 22:00 提问

为什么两个按钮我随便点击一个按钮都会更新成功,插入按钮我需要的是插入更能而不是更新功能,求大神指教

<%@ page import="com.trs.constants.AuthConstants"%>
<%@ page import="org.springframework.validation.FieldError"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>



短信管理-修改短信模板
images/jquery.min.js">
<br> <div class="titlePopup_head"><br> <span>修改短信模板</span><br> <img src="<%=basePath %>images/cls.jpg&quot; class=&quot;titlePopup_head_right&quot; onclick=&quot;cancelbtn()&quot;&gt;<br> </div><br> <div class="smsNewAndUpdate_Popup_con"><br> <div class="smsNewAndUpdate_Popup_main"><br> <form class="form-horizontal" id="updateSmsTemp" action="<%=basePath%>smsTemp.do?method=updateSmsTemp&quot; method=&quot;post&quot;&gt;<br> <input type="hidden" name="stId" value="${requestScope.mrsSmsTemp.stId}"><br> <fieldset><br> <div class="popupInfo_left"><br> <span>名称:</span><input type="text" placeholder="" class="input-xlarge" value="${requestScope.mrsSmsTemp.tempName}" id="tempName" name="tempName"/><span class="required_Info"><em></span><br> </div><br> <div class="popupInfo_left"><br> <span>类型:</span><br> <div class="drop_down"><br> <select class="border_clr" id="tempType" name="tempType" value="${requestScope.mrsSmsTemp.tempType}"><br> <option value="1" <c:if test="${requestScope.mrsSmsTemp.tempType eq '1'}">selected<a href="/c:if">/c:if</a> &gt;自取</option><br> <option value="2" <c:if test="${requestScope.mrsSmsTemp.tempType eq '2'}">selected<a href="/c:if">/c:if</a> &gt;邮寄</option><br> <option value="3" <c:if test="${requestScope.mrsSmsTemp.tempType eq '3'}">selected<a href="/c:if">/c:if</a>&gt;打卡</option><br> </select><br> </div><br> </div><br> <div class="popupInfo_left"><br> <span>内容:</span><br> <div class="drop_down"><br> <select class="border_clr" id="ditchId" name="ditchId" value="${requestScope.mrsSmsTemp.ditchId}"><br> <option value="0" <c:if test="${requestScope.mrsSmsTemp.ditchId eq '0'}">selected<a href="/c:if">/c:if</a> &gt;渠道选择</option><br> <option value="1" <c:if test="${requestScope.mrsSmsTemp.ditchId eq '1'}">selected<a href="/c:if">/c:if</a> &gt;APP</option><br> <option value="2" <c:if test="${requestScope.mrsSmsTemp.ditchId eq '2'}">selected<a href="/c:if">/c:if</a> &gt;网站</option><br> <option value="3" <c:if test="${requestScope.mrsSmsTemp.ditchId eq '3'}">selected<a href="/c:if">/c:if</a>&gt;纸媒</option><br> <option value="4" <c:if test="${requestScope.mrsSmsTemp.ditchId eq '4'}">selected<a href="/c:if">/c:if</a>&gt;杂志</option><br> </select><br> </div><br> <div class="drop_down"><br> <select class="border_clr" ><br> <option value="标题">标题</option><br> <option value="作者">作者</option><br> <option value="时间">时间</option><br> </select><br> </div><br> <button class="border_clr0" onclick="insert()">插入</button><br> </div><br> <div class="popupInfo_left"><br> <textarea class="ml42 popupInfo_right_area" name="tempContent" id="tempContent" cols="57" rows="7" >${requestScope.mrsSmsTemp.tempContent }</textarea><span class="required_Info1"></em></span><br> </div><br> <div class="popupInfo_left"><br> <span>说明:</span><br> <textarea class="popupInfo_right_area" name="tempDescription" id="tempDescription" cols="57" rows="7">${requestScope.mrsSmsTemp.tempDescription }</textarea><br> </div><br> </fieldset><br> </form><br> <div class="smsNewAndUpdatePopup_footer"><br> <button class="news-role-btn-success" onclick="successBtn()">确定</button><br> <button class="news-role-btn" onclick="cancelbtn()">取消</button><br> </div><br> </div><br> </div><br> </div></p> <script type="text/javascript"> function insert() { } //关闭弹出层 function cancelbtn() { var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); } function successBtn(){ var tempName = document.getElementById("tempName").value; var tempContent = document.getElementById("tempContent").value; if(tempName==""){ layer.tips('模板名称不能为空!', '#tempName', { tips: 3 }); }else if(tempContent==""){ layer.tips('模板内容不能为空!', '#tempContent', { tips: 3 }); }else{ document.getElementById("updateSmsTemp").submit(); } }
<c:forEach items="${requestScope.hasError}" var="hasError" >
    <c:set var="_haserror" scope="page" value="${hasError }"/>
</c:forEach>
<c:if test="${_haserror!=null}">
    <script>
    layer.tips('${_haserror}', '#tempName', {
            tips: 3
        });
    </script>
</c:if>
<%
    //如果没有错误信息则代表成功,关闭当前窗口
%>
<c:if test="${requestScope.success eq 'success'}">
    <script>    
        var index = parent.layer.getFrameIndex(window.name);
        parent.location.reload();
        parent.layer.close(index);

    </script>
</c:if>
(function($){ $.fn.extend({ insertAtCaret: function(myValue){ var $t=$(this)[0]; if (document.selection) { this.focus(); sel = document.selection.createRange(); sel.text = myValue; this.focus(); } else if ($t.selectionStart || $t.selectionStart == '0') { var startPos = $t.selectionStart; var endPos = $t.selectionEnd; var scrollTop = $t.scrollTop; $t.value = $t.value.substring(0, startPos) + myValue + $t.value.substring(endPos, $t.value.length); this.focus(); $t.selectionStart = startPos + myValue.length; $t.selectionEnd = startPos + myValue.length; $t.scrollTop = scrollTop; } else { this.value += myValue; this.focus(); } } }); })(jQuery); $(".border_clr0").change(function(){ $("#tempContent").insertAtCaret($(this).val()); });

1个回答

dcxy0
dcxy0   Ds   Rxr 2016.03.15 22:30

代码格式化一下吧,或者放在coding.net上,分享下地址好一些,你可能是在更新的时候没有带上ID。

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!