搜索墙首页  编程技术  java  asp  ajax  php  c/c#/c++  数据库  oracle  mysql  db2  操作系统  windows  linux  股吧
首页 > 编程 > java
 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>
 1         
您的发言将按有关规定都会存档,您须为所发表后果负责,请您遵纪守法并注意语言文明。
标题:如何在jsp中使用javascript,struts标签和jsp页面变量之间互相传值
热门关注
标题回复点击
china area part 103309
数据库连接字符串大全(转)02893
福州地铁最新规划图,1号线2014年建成02446
UML建模工具Rational Rose 2007 破解 下载地址21420
Winkawkas游戏中英文名对照表01363
驱动 EPSON TM-U220PDmodel m188d ATM 301gSC 下载31340
mysql 语法手册 chm 下载01100
400多个JavaScript特效大全01096
e的精确值是多少?[z]3986
Struts Menu开发向导0981
搜索墙@2009 www.pkwall.com all rights reserved QQ:276471788 [京ICP备09111534号]
声明:本站部分数据来源于网络,仅供参考,如有版权问题,请联系我们,我们将及时删除!转载本站请注明来源