2014-07-11 24 views
1
Hello i have this form:<form method="post" action="Toplanti.jsp"> 
    <input type="hidden" id="dl" name="dl" value=""> 

這HS編碼:如何在JSP變量傳遞給JavaScript方法與參數

<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 。有沒有辦法做到這一點?謝謝

+0

「但是這種方法沒有得到參數p」。 - 你期望它得到什麼價值?它實際上得到了什麼? onclick屬性中的JavaScript(不是生成JavaScript的JSP,在查看源代碼時可以在瀏覽器中看到的最終JS)是什麼樣的? – Quentin

回答

1

你不使用分號

試試這個:

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