Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将多个参数从jsp页面传递到javascript函数_Javascript_Jsp - Fatal编程技术网

将多个参数从jsp页面传递到javascript函数

将多个参数从jsp页面传递到javascript函数,javascript,jsp,Javascript,Jsp,这看起来像是一个复制品。但事实并非如此 这是我的代码: <script language="JavaScript"> function popupwin(qid) { var myWindow = window.open("", "", "width=800, height=600"); myWindow.document.write("<p> Qid = "+qid); } </script> ....... <% try{

这看起来像是一个复制品。但事实并非如此

这是我的代码:

<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>           
<%
    }

函数popupwin(qid)
{
var myWindow=window.open(“,”,“宽度=800,高度=600”);
myWindow.document.write(“Qid=“+Qid”);
}
.......

没有理由不工作,我怀疑你有语法错误。尝试以下方法

<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
}

函数popupwin(qid、testVal){
log(testVal);//您应该在浏览器的控制台中看到“test”
}

原来我没有使用双引号来指定onclick的值。虽然我不知道我是怎么错过的。非常感谢。