Struts 1.5:如何在textField中显示值

时间:2013-11-12 10:06:26

标签: java javascript struts struts-1

我想在文本框中显示一个值,我想只使用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>

  • 有两个文本字段,其属性名称为month&amp;年。
  • 我想在其中显示值

1 个答案:

答案 0 :(得分:0)

struts中的

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