这是A.jsp
<script>
function showSpOnLoad()
{
//all of ajax code
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("ajaxData").innerHTML=xmlhttp.responseText;
}
xmlhttp.open("GET",'B.jsp?date='+date+'',true);
}
</script>
<body>
<span class="inner-link-text2" id="sp" style="cursor:pointer" onclick="showSpOnLoad()">My Stats</span>
<div id="ajaxData" align="center"></div>
</body>
在 A.jsp 中,您可以看到在单击Span
My Stats时,我只是调用一个 js 函数showSpOnLoad()
将打开另一个B.jsp
位于 div 中的jsp 页面ajaxData
。
现在B.jsp
,我只有一个显示文本字段、链接和按钮的脚本。这是B.jsp
<%
String output = "";
output += "<input name='date' type='text' id='date' value=''style='margin-left=10px;'/>";
output += "<a href='#' ><img src='images/img.gif' border='0' id='cal_img' ></a>";
output += "<input type='submit' value='Generate Stats' onclick='getVal();'/>";
%>
<%= output %>
<link href="js/calendar-blue.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/calendar.js"></script>
<script type="text/javascript" src="js/calendar-en.js"></script>
<script type="text/javascript" src="js/calendar-setup.js"></script>
<script type="text/javascript">
Calendar.setup({
inputField : "date", // id of the input field
ifFormat : "%Y-%m-%d", // format of the input field
button : "cal_img", // trigger for the calendar (button ID)
singleClick : true
});
</script>
此页面显示正常,但如您所见,我附上了一个带有文本字段的日历<a href>
。
现在的问题是,当我单击此链接时,它从不显示日历。
我已将此日历 js 放在 A.jsp 中,但它也从未在那里工作。现在我无法理解这个问题。
专家有什么建议吗?