当前位置: 代码迷 >> Java相关 >> jsp在div中嵌入新的button按钮,不能触发
  详细解决方案

jsp在div中嵌入新的button按钮,不能触发

热度:229   发布时间:2013-04-25 21:27:46.0
jsp在div中嵌入新的button按钮,不能触发
客户姓名:<input type="text" id="creditName" name="creditName"/>
<br /><br />
签定日期:<s:textfield name="createDate" id="createDate"></s:textfield>
<br /><br />
<input type="button" id="search-button" value="查询"/>

<input type="button" id="addNum" name="addNum"/>
<s:div id="selectInfor" style="display:none;">
    <tr>
        <th><b>客户编号</b></th>
        <th><b>客户姓名</b></th>
        <th><b>申请资金</b></th>
        <th><b>操作</b></th>
    </tr>
</s:div>
<input type="text" id="clientid" name="clientid"/>
<input type="text" id="proposername" name="proposername"/>
<div id="infor">
<table class="table_box table_bottom_border" id="resultListTable">
    <tr>
        <th><b>客户编号</b></th>
        <th><b>客户姓名</b></th>
        <th><b>申请资金</b></th>
        <th><b>操作</b></th>
    </tr>
        <s:iterator value="creditList" status="index" var="var">
            <tr>
                <td>${clientid}</td>
                <td>${proposername }</td>
                <td>${applymoney }</td>
                <td><input type="button" class="getInfor" value="确定"/></td>
            </tr>
        </s:iterator>
</table>
</div>
<script type="text/javascript">
<!--
        $("#search-button").click(function(){
            var putin = $("#creditName").serializeArray();
            $.ajax({
                url : "creditApplyTestAction.action",type : "post",dataType:"json",data : putin,timeout : 20000,// 设置请求超时时间(毫秒)。
                contentType: "application/x-www-form-urlencoded; charset=utf-8",
                beforeSend: function(XMLHttpRequest){
                },
                success : function(data) {
                    $("#infor").remove();
                    var html="";
                    html += "<table class='table_box table_bottom_border' id='newInforList'& gt;<tr><th><b>客户编号</b>< /th><th><b>客户姓名</b></th><th><b>申请 资金</b></th><th><b>操作</b></th>< /tr>";
                    html += ("<tr><td>" + data["clientid"] + "</td><td>" + data["proposername"] + "</td><td>" + data["applymoney"] + "</td><td>" + "<input type='button' class=\"getInfor\" id='newButton' value='确定'/>" + "</td></tr></table>");
                    $("#selectInfor")(html); //将拼装后的代码嵌入到<div>标签内。
                },
                 error: function(XMLHttpRequest, textStatus, errorThrown) {
                     alert(textStatus);
                 }
            });
        });
         
        $(".getInfor").click(function(){
            $("#clientid").val($(this).parent("td").parent("tr").children("td:eq(0)").text());
            $("#proposername").val($(this).parent("td").parent("tr").children("td:eq(1)").text());
            $("#OpenDialog").dialog("close");
        });
            
//-->
</script>
搜索更多相关的解决方案: 姓名  display  button  style  

----------------解决方案--------------------------------------------------------
问题具体点儿?
----------------解决方案--------------------------------------------------------
代码没有问题 问题是你要把AJAX 该成同步就行了

----------------解决方案--------------------------------------------------------
如果逻辑感觉没问题,可以考虑用F12断点调试
----------------解决方案--------------------------------------------------------
  相关解决方案