0

我想在文本框中显示一个值,并且我只想使用 javascript 来完成。

这是情况:

  • 当我单击日历图像时,它会打开一个仅显示月份和年份的窗口。
  • 选定的月份和年份显示在标签中。

现在我的要求是在文本框中显示相同的内容,因为我想将其分配给 bean 属性。

代码 :

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"      
   "http://www.w3.org/TR/html4/loose.dtd">
 <html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1256">
    <meta name="description" content="Javascript popup date and time picker control (javascript calendar)">
    <meta name="keywords" content="free JavaScript Calendar, javascript, client side, pop, popup, timestamp, date, picker, database, control">
    <noscript>
    <meta http-equiv="Refresh" content="1;  url=JavaScriptCheck.do">
    </noscript>
    <title><fmt:message key="sms.banking.title"/></title>
    <link href="css/ie.css" rel="stylesheet" type="text/css">
     <link href="css/monthYearCalendar.css" rel="stylesheet" type="text/css" />


    <script src="js/common.js"> </script>

    <script language="javascript" src="js/PopupWindow.js"></script>

    <script language="javascript" src="js/AnchorPosition.js"></script>


    <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script type="text/javascript" src="js/monthYearCalendar.js"></script>

    <script type="text/javascript">
$(document).ready(function() {
    monthYearCalendar.init("boxMonthYear",show);
     monthYearCalendar.init(
    $("#year").html("Year :"+monthYearCalendar.selectedYear),
    $("#month").html("Month :"+monthYearCalendar.monthNames[monthYearCalendar.selectedMonth - 1])

);


});
function show() {
    $("#month").html("Month :"+monthYearCalendar.monthNames[monthYearCalendar.selectedMonth - 1]);
     $("#year").html("Year :"+monthYearCalendar.selectedYear );


}

</head>
<body leftmargin="0" topmargin="0">
    <html:form action="monthlyChargeReport" method="POST">
    <table border="0" cellpadding="0" cellspacing="0" class="text" width="400">

    <tr>
    <td height="24"  colspan="3" class="formlabelcolheadselect">&nbsp;<fmt:message key="reports.sms"/> -<fmt:message key="report.monthlycharge"/></td>
       <tr>
            <td height="5" colspan="3" class="errormsg">&nbsp;<html:errors/></td>
        </tr>
         <tr  >
            <td class="msgtext">&nbsp;</td>
            <td class="msgtext" id="month">Month :

            </td>
            <td>
               <html:text property="month" value="${monthYearCalendar.selectedMonth}"/>
            </td>
         </tr>
         <tr>
            <td colspan="4">&nbsp;</td>
        </tr>
         <tr  >
            <td class="msgtext">&nbsp;</td>
            <td class="msgtext" id="year">Year :
                <html:text property="year" value="${monthYearCalendar.selectedYear}"/>
            </td>
             <td  id="boxMonthYear"></td>
          </tr>

           <tr>
            <td colspan="4">&nbsp;</td>
        </tr>
        <tr>
        <tr class="textsml" id=TDSHADE2 >
            <td align=left>&nbsp;</td>
            <td align=left>&nbsp;</td>
            <td align=left>


            <html:button property="button" value="Submit" styleClass="buttons" title="Submit" onclick="javascript:document.forms[0].action='monthlyChargeReport.do';document.forms[0].submit();" />
                &nbsp;&nbsp;&nbsp;&nbsp;<html:button property="button" value="Back" styleClass="buttons" title="Back"  onclick="javascript:document.forms[0].action='reportStats.do';document.forms[0].submit();" />
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                  </td>
        </tr>
        <tr class="simpletext" id=TDSHADE2>
            <td colspan="4"class="simpletext"><div align="left"><fmt:message key="fields.mark"/></div>
            </td>
        </tr>
        <tr>
            <td colspan="4"><%@ include file="copyRight.htm"%></td>
        </tr>
    </table>
</body>
    <html:javascript formName="monthlyChargeForm"/>
</html:form>

  • 有两个属性名称为月和年的文本字段。
  • 我想显示其中的值
4

1 回答 1

0

struts 中的文本标签不支持属性属性...所以它不会显示你可以使用 s:property 的值,如果你的值在行动中绑定,那么你可以使用 %{varible name } 来获取值http:/ /struts.apache.org/release/2.0.x/docs/text.html

于 2013-11-24T16:22:30.153 回答