繁体   English   中英

如何将jsp变量作为参数传递给javascript方法

[英]How to pass a jsp variable to a javascript method as parameters

Hello i have this form:<form method="post" action="Toplanti.jsp">
   <input type="hidden" id="dl" name="dl"  value="">

这是他的代码:

<table>
<%for(int i=1;i<od.odasayisi()+1;i++){ %>
    <tr>
    <%for(int j=8;j<21;j++){  %>
        %><td id="bos">
        <input type="button" onclick="oda(<%=i%>)"><%} 

而这个js函数

    function oda(p){
    document.getElementById('dl').value=p
    var ad=document.getElementById('dl').value
    window.open("Odaici.jsp?a="+ad);
}

但是这个方法没有得到参数p,有没有办法做到这一点?

你不用分号

尝试这个:

function oda(p){
   document.getElementById('dl').value=p;
   var ad=document.getElementById('dl').value;
   window.open("Odaici.jsp?a="+ad);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM