1
1楼 dilong95_95 2007-04-05 12:43:02 哪位研究过:如何在jsp中使用javascript,struts标签和jsp页面变量之间互相传值吗? 2楼 xokao 2007-04-05 13:08:03 sample: <%String k= " ";%> <!--java传值给js or jsp :--> <input value= " <%=k%> "> //传给js var a = ' <%=k%> '; js or jsp不能直接传给java.因为java在jsp生成页面的时候就执行完了。 除非你重新把值传会给本页,然后在用request.getParameter( " ")得到值, or ajax也可以。 3楼 dilong95_95 2007-04-05 13:31:06 <logic:iterate id= "noticeBean " name= "noticeList "> <c:out value= "${noticeBean.title} "/> </logic:iterate> 我要是想将noticeBean.title的值赋值给jsp的一个变量可以实现吗? 4楼 yanhuaxie 2007-04-05 13:57:51 给你一个例子吧,根据需要改写就ok了.
<script language= "JavaScript "> //java 值 --> js function init() { s2 = TestForm.elements( "auction.regCode ").selectedIndex; if (s2 == 0) { alert( "数据不能为空 "); return false; } s2 = TestForm.elements( "auction.stockCode ").value; if (s2==null || s2== ' ') { alert( "数据不能为空 "); return false; } return true; } //js --- > java function getInfo() { TestForm.elements( "stockType ").selectedIndex = ' '; TestForm.elements( "stockType ").value = ' '; TestForm.elements( "auction.startPrice ").value = 0.0; TestForm.elements( "auction.orderVolume ").value = 0; TestForm.elements( "auction.gage ").value = 0.0; TestForm.elements( "auction.payDelayDays ").value = 0; TestForm.elements( "auction.startPrice ").value = 0.0; //pForm.getAuction().setStockCode( " "); TestForm.elements( "auction.regCode ").value = ' '; TestForm.operation.value= 'getInfo '; TestForm.submit(); } </script> <table width= "98% " border= "0 " cellpadding= "2 " cellspacing= "1 " bgcolor= "#dbeaf5 " align= "center "> <html:form action= "/auction/TestAction.do " method= "post "> <tr> <td bgcolor= "#E0EAF0 " width= "90 " nowrap > 代码 </td> <td bgcolor= "#FFFFFF " width= "100 " nowrap > <html:text styleClass= "input " name= "TestForm " property= "auction.stockCode " maxlength= "6 " onkeyup= "stockCodeKeyUp() "/> </td> <td width= "70 " bgcolor=#e0eaf0 > <logic:equal name= "TestForm " property= "auction.appliedBy " value= " "> <input type= "button " name= "btnGetInfo " value= "确定 " class= "btn " onclick = "getInfo(); " disabled= "true "> </logic:equal> <logic:equal name= "TestForm " property= "auction.appliedBy " value= "0000000000 "> <input type= "button " name= "btnGetInfo " value= "确定 " class= "btn " onclick = "getInfo(); " disabled= "true "> </logic:equal> <logic:notEqual name= "TestForm " property= "auction.appliedBy " value= "0000000000 "> <logic:notEqual name= "TestForm " property= "auction.appliedBy " value= " "> <input type= "button " name= "btnGetInfo " value= "确定 " class= "btn " onclick = "getInfo(); " > </logic:notEqual> </logic:notEqual> </td> </tr> </html:form> </table>
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源
| ||||||||||||||||||||||||||||||||||||||||