为什么不能直接通过document.getElementById("<%= txtCard.ClientID %>")

12 篇文章 0 订阅
8 篇文章 0 订阅
function prjClrInfo(ipt)
{            
    var prjclr = document.getElementById("<%= txtClr.ClientID %>");           
    prjclr.value = ipt.GetTextByName("clr")+"  "+ipt.GetTextByName("flwsht");          
    var card=document.getElementById("txtCard_text");
    var prj=document.all("txtPrj_text").value;
    card.sqlFilter="and prj='"+prj+"'";                      
    prjclr.readOnly = "readonly";    
} 


<td style="width:10%">生产单:</td>
<td style="width:23%">
    <KYWEBCTL:EPDblTextBox ID="txtPrj" runat="server" DelwithFunction="prjClrInfo" DataType="ColPrjMessRight" Required="true"></KYWEBCTL:EPDblTextBox>
</td>
<td style="width:10%">颜色/花型:</td>
<td style="width:23%">
    <KYWEBCTL:EPTextBox ID="txtClr" runat="server" DataType="EP_TXT"></KYWEBCTL:EPTextBox>
</td>
<td style="width:10%">卡号:</td>
<td style="width:23%">
    <KYWEBCTL:EPDblTextBox ID="txtCard" runat="server" DataType="CardMess" Required="false"/>
</td>                              

用生产单过滤卡号的时候,不能直接通过document.getElementById("<%= txtCard.ClientID %>")获取该卡号控件的ID,后面用浏览器调试的时候,发现在浏览器将该控件

<KYWEBCTL:EPDblTextBox ID="txtCard" ……

解析为

<span><input name="txtCard$text" type="text" id="txtCard_text" title="您可以输入部分字符,以便打开选择对话框!
Input Some Character Open Dialog Box!" isAutoBack="False" isEdit="False" delwithFunction="" mouseOpen="" οnblur="javascript:;if(this.isChanged){resetDBTextBox(this);OpenModalDialog(this,"/jetpoint");this.isChanged = false;};" οnchange="javascript:this.isChanged = true;" isChanged="false" dataType="CardMess" isMultiSelect="False" IsPartSearch="False" textField="" sqlFilter="" xml="" style="border-color:DodgerBlue;" /><input name="txtCard$id" type="text" value="-1" readonly="readonly" id="txtCard_id" οnchange="javascript:;" style="display:none;" /><input name="txtCard$xml" type="text" readonly="readonly" id="txtCard_xml" style="width:40px;display:none;" /><img id="txtCard_image" title="您可以鼠标单击打开选择对话框!
Click Mouse Left key Open Dialog Box!" οnclick="resetDBTextBox(this.parentNode.childNodes[0]);OpenModalDialog(this.parentNode.childNodes[0],"/jetpoint")" src="/jetpoint/Resource/picture/button/Editable.gif" style="border-width:0px;vertical-align:text-bottom;cursor:hand;height:20px;width:21px;" /><input type="hidden" name="txtCard$searchValue" id="txtCard_searchValue" /></span>

无奈只能直接这样使用txtCard_text作为ID了。

----------------------------------


问题已解决,该控件是他们自定义的控件,重写之后就不能这样取ID了。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%--<html>--%> <%--<head>--%> <%-- <title>Title</title>--%> <%--</head>--%> <%--<body>--%> <%--<div>--%> <%-- <div style="color: #37ff00">${requestScope.msg}</div>--%> <%-- 用户名:<input type="text" name="username" > <br>--%> <%-- 密 码:<input type="password" name="password" > <br>--%> <form action="/userlogin" method="post"> <%-- <input type="submit" value="登录">--%> <%-- </form>--%> <%-- </div>--%> <%--</body>--%> <%--</html>--%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>注册表单</title> <style> .container { width: 300px; margin: 0 auto; padding: 20px; border: 1px solid #ccc; } .form-group { margin-bottom: 10px; } .form-group label { display: block; margin-bottom: 5px; } .form-group input { width: 100%; padding: 5px; } .form-group button { width: 100%; padding: 10px; background-color: #4CAF50; color: white; border: none; cursor: pointer; } </style> </head> <body> <div class="container"> <h2>登录</h2> <form id="login-form"> <div class="form-group"> <label for="username">用户名:</label> <input type="text" id="username" name="username" required> </div> <div class="form-group"> <label for="password">密码:</label> <input type="password" id="password" name="password" required> </div> <div class="form-group"> <button type="submit">登录</button> </div> </form> </div> <script> document.getElementById('login-form').addEventListener('submit', function(event) { event.preventDefault(); // 阻止表单提交的默认行为 var username = d帮我让这个代码把账号密码发给LoginServlet进行逻辑判断
最新发布
07-24

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值