- JScript code
<% Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -1); SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd"); String newTime = sf.format(cal.getTime()); %> <table> <tr> <td> 查询时间: <input id="begintime" name="begintime" type="text" value="<%=newTime%>" maxlength="20" style="width:80px" readonly/> </td> </tr> </table> <script type="text/javascript"> $(document).ready(function() { var newTime = <%=newTime%>; alert(newTime); }); </script>
为什么newTime在<table>中的值就是2012-09-10而在<script>中取得值就是1993呢,想在<script>中取得2012-09-10怎么弄呢
------解决方案--------------------
。。。你把2012-09-10的-看成减号,,算算看。。。。
- JScript code
var newTime = <%=newTime%>;
------解决方案--------------------