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

时间:2014-07-11 06:32:53

标签: javascript jsp

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。有没有办法做到这一点?谢谢

1 个答案:

答案 0 :(得分:1)

您不使用分号

试试这个:

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