这似乎是重复的。但它不是。
这是我的代码:
<script language="JavaScript">
function popupwin(qid)
{
var myWindow = window.open("", "", "width=800, height=600");
myWindow.document.write("<p> Qid = "+qid);
}
</script>
.......
<%
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","Shravya17");
ps=con.prepareStatement("select * from questions where category = ?");
ps.setString(1,cat);
rs=ps.executeQuery();
while(rs.next()){
qid = rs.getInt(1);
ques = rs.getString(2);
cat = rs.getString(3);
a = rs.getString(4);
b = rs.getString(5);
c = rs.getString(6);
d = rs.getString(7);
ca = rs.getString(8);
%>
<tr align = "center">
<td> <%= qid %> </td>
<td> <%= ques %> </td>
<td> <%= cat %> </td>
<td> <%= a %> </td>
<td> <%= b %> </td>
<td> <%= c %> </td>
<td> <%= d %> </td>
<td> <%= ca %> </td>
<td>
<input type="submit" value="Edit" onclick=(popupwin(<%=qid%>));/>
</td>
</tr>
<%
}
这很好用。
但是如何在函数调用中传递多个参数?
我尝试传递用逗号分隔的参数,但它没有用。
请帮忙!
答案 0 :(得分:0)
没有理由它不应该工作,我怀疑你有语法错误。尝试以下方法。
<td>
<input type="submit" value="Edit" onclick="(popupwin(<%=qid%>, 'test'))" />
</td>
function popupwin(qid, testVal) {
console.log(testVal); // you should see 'test' in your browser's console
}