我有一个包含日历弹出窗口和文本输入字段的程序。当用户点击文本输入字段时,我正在进行onclick以检查日历字段的值是否不为零。如果是输入字段,则将readonly设置为false。
我的onclick功能仅在用户在页面加载后单击文本输入两次后才起作用。我需要这个代码才能在第一次点击时工作,每次点击都会超过它。经过一些测试后,此问题仅发生在Internet Explorer中。
我使用的代码是:
<html>
<head>
<meta http-equiv="Pragma" content="no-cache">
<title>t</title>
<script language="JavaScript" type="text/javascript" src="/websmart/v5/javascript/imgswap.js"></script>
<script language="JavaScript" type="text/javascript" src="/websmart/v5/javascript/mm_menu.js"></script>
<link rel="StyleSheet" href="/websmart/v5/stylesheets/birdseyeblue.css" media="screen" type="text/css">
<SCRIPT LANGUAGE="JavaScript" SRC="/stars/html/CalendarPopup.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">document.write(CalendarPopup_getStyles());</SCRIPT>
<script type="text/javascript">
var CheckVal = function (fieldNum)
{
var str = 'BQXAWDDT'+fieldNum;
var str2 = 'BQXGNB'+fieldNum;
var DVal = document.getElementById(str).value;
if(DVal == "00/00/0000")
{
document.getElementById(str2).readOnly = true;
}
else
{
document.getElementById(str2).readOnly = false;
}
}
</script>
</head>
<body>
<center>
<P>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">
<TR>
<TD WIDTH="100"><IMG SRC="/Stars/HTML/STAC001/left_image.jpg" WIDTH="100" HEIGHT="50" ALIGN="BOTTOM" BORDER="0"></TD>
<TD WIDTH="100%"><IMG SRC="/Stars/HTML/STAC001/center.jpg" ALIGN="BOTTOM" BORDER="0"></TD>
<TD WIDTH="400"><IMG SRC="/Stars/HTML/STAC001/right_image.jpg" ALIGN="BOTTOM" BORDER="0"></TD>
</TR>
</TABLE>
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="100%">
<TR>
<TD HEIGHT="20" BGCOLOR="#6392C6">
<P ALIGN="CENTER">
<font color=red>**Test**</font> </td>
</TR>
</TABLE>
</TD>
</TR>
</TABLE>
<B><font color="#CC0000">Update Source Details</font></b>
<br>
<form action="PATUPD.pgm" id="PATUPDADD" name="PATUPDADD" method="post">
<input type="hidden" name="task" value="endupd">
<input type="hidden" name="SelComp" value="STAC">
<input type="hidden" name="SelSchool" value="001">
<input type="hidden" name="SelStudent" value="0000000033">
<input type="hidden" name="SelSource" value="AppFee">
<input type="hidden" name="SelYear" value="2012">
<table>
<tr>
<td class="text"><b>Student #: 33 Robert Amell</b></td>
</tr>
<tr>
<td class="text"><b>Source Code: AppFee Application Fee Payment</b></td>
</tr>
</table>
<table border="1" bordercolor="#FFFFFF" cellpadding="0" cellspacing="0">
<tr class="bar">
<th style="display:none;"></th>
<td valign="top" width="40">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="bar">
<td width="10%" align="left" valign="top"><img src="/websmart/v5/tpli/birdseyeblue/corner_left.gif" width="11" height="20"></td>
<td width="90%">Date</td>
</tr>
</table>
</td>
<td width="100" class="text2" valign="top">Projected Amount</td>
<td valign="top">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="bar">
<td width="90%">Actual Amount</td>
<td width="10%" align="right" valign="top"><img src="/websmart/v5/tpli/birdseyeblue/corner_right.gif" width="11" height="20"></td>
</tr>
</table>
</td>
</tr>
<tr>
<input type="hidden" name="Detrrn" value="000002905">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT1" id="BQXAWDDT1" value="01/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT1,'anchor01','MM/dd/yyyy'); return false;" NAME="anchor01" ID="anchor01"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB1" onclick="CheckVal(1); return false;" size="9" maxlength="9" value=12.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000002906">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT2" id="BQXAWDDT2" value="02/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT2,'anchor02','MM/dd/yyyy'); return false;" NAME="anchor02" ID="anchor02"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB2" onclick="CheckVal(2); return false;" size="9" maxlength="9" value=1233.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000002907">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT3" id="BQXAWDDT3" value="03/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT3,'anchor03','MM/dd/yyyy'); return false;" NAME="anchor03" ID="anchor03"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB3" onclick="CheckVal(3); return false;" size="9" maxlength="9" value=123.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000052275">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT4" id="BQXAWDDT4" value="03/08/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT4,'anchor04','MM/dd/yyyy'); return false;" NAME="anchor04" ID="anchor04"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB4" onclick="CheckVal(4); return false;" size="9" maxlength="9" value=1000.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000002908">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT5" id="BQXAWDDT5" value="04/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT5,'anchor05','MM/dd/yyyy'); return false;" NAME="anchor05" ID="anchor05"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB5" onclick="CheckVal(5); return false;" size="9" maxlength="9" value=234.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000002909">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT6" id="BQXAWDDT6" value="04/03/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT6,'anchor06','MM/dd/yyyy'); return false;" NAME="anchor06" ID="anchor06"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB6" onclick="CheckVal(6); return false;" size="9" maxlength="9" value=></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000052276">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT7" id="BQXAWDDT7" value="05/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT7,'anchor07','MM/dd/yyyy'); return false;" NAME="anchor07" ID="anchor07"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB7" onclick="CheckVal(7); return false;" size="9" maxlength="9" value=></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000002910">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT8" id="BQXAWDDT8" value="06/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT8,'anchor08','MM/dd/yyyy'); return false;" NAME="anchor08" ID="anchor08"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB8" onclick="CheckVal(8); return false;" size="9" maxlength="9" value=14.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000002911">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT9" id="BQXAWDDT9" value="07/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT9,'anchor09','MM/dd/yyyy'); return false;" NAME="anchor09" ID="anchor09"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB9" onclick="CheckVal(9); return false;" size="9" maxlength="9" value=41.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000002912">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT10" id="BQXAWDDT10" value="08/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT10,'anchor10','MM/dd/yyyy'); return false;" NAME="anchor10" ID="anchor10"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB10" onclick="CheckVal(10); return false;" size="9" maxlength="9" value=51.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000002913">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT11" id="BQXAWDDT11" value="09/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT11,'anchor11','MM/dd/yyyy'); return false;" NAME="anchor11" ID="anchor11"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB11" onclick="CheckVal(11); return false;" size="9" maxlength="9" value=15.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000002914">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT12" id="BQXAWDDT12" value="10/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT12,'anchor12','MM/dd/yyyy'); return false;" NAME="anchor12" ID="anchor12"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB12" onclick="CheckVal(12); return false;" size="9" maxlength="9" value=51.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000002915">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT13" id="BQXAWDDT13" value="11/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT13,'anchor13','MM/dd/yyyy'); return false;" NAME="anchor13" ID="anchor13"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB13" onclick="CheckVal(13); return false;" size="9" maxlength="9" value=61.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000002916">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT14" id="BQXAWDDT14" value="12/01/2012" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT14,'anchor14','MM/dd/yyyy'); return false;" NAME="anchor14" ID="anchor14"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB14" onclick="CheckVal(14); return false;" size="9" maxlength="9" value=133.00></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000000000">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT15" id="BQXAWDDT15" value="00/00/0000" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT15,'anchor15','MM/dd/yyyy'); return false;" NAME="anchor15" ID="anchor15"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB15" onclick="CheckVal(15); return false;" size="9" maxlength="9" readonly value=></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000000000">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT16" id="BQXAWDDT16" value="00/00/0000" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT16,'anchor16','MM/dd/yyyy'); return false;" NAME="anchor16" ID="anchor16"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB16" onclick="CheckVal(16); return false;" size="9" maxlength="9" readonly value=></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000000000">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT17" id="BQXAWDDT17" value="00/00/0000" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT17,'anchor17','MM/dd/yyyy'); return false;" NAME="anchor17" ID="anchor17"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB17" onclick="CheckVal(17); return false;" size="9" maxlength="9" readonly value=></td>
<td width="90" class="textN"></td>
</tr><tr>
<input type="hidden" name="Detrrn" value="000000000">
<td width="150" class="text"><SCRIPT LANGUAGE="JavaScript">var cal1 = new CalendarPopup();</SCRIPT>
<INPUT TYPE="text" READONLY NAME="BQXAWDDT18" id="BQXAWDDT18" value="00/00/0000" SIZE=10>
<A HREF="#" onClick="cal1.select(document.forms[0].BQXAWDDT18,'anchor18','MM/dd/yyyy'); return false;" NAME="anchor18" ID="anchor18"><img src="/stars/html/calbtn.gif" border="0" height="21" width="34" align="absmiddle"></A></td>
<td width="70"><input type="textN" name="BQXGNB" id="BQXGNB18" onclick="CheckVal(18); return false;" size="9" maxlength="9" readonly value=></td>
<td width="90" class="textN"></td>
</tr><input type="hidden" name="rcdcnt" value="18">
</table>
<br>
<br>
<input type="submit" value="Update"> <input type="button" value="Cancel" onclick="window.location='PATUPD.pgm?Task=DEFAULT&SelComp=STAC&SelSchool=001&SelStudent=0000000033&SelSource=AppFee&Page=00000&rnd=38821&SelYear=2012'">
</form>
<P>
<TABLE ALIGN="CENTER" BORDER="0" CELLPADDING="0" CELLSPACING="0" WIDTH="80">
<TR>
</TR>
<TR>
<TD WIDTH="80" ALIGN="CENTER"><IMG SRC="/htdocs/STARS.gif" WIDTH="80" HEIGHT="30" P ALIGN="CENTER"></TD>
</TR>
</P>
</center>
</body>
</html>