jsp onclick如何传递string参数

<html>
<head>
<script>
function updatestatus(str){
alert(str);
}
function deletecompany(str1){
alert(str1)
//window.location.href="deletecompany.jsp?cid="+str1;
}
</script>
</head>
<body>
<%
String status=request.getParameter("status");
//String id=request.getParameter("id");
String id="0005";
out.println(id);
if(status.equals("approve")){
out.println("<input type='button' value='update' onclick='updatestatus(\""+id+"\")'/>");
}else if(status.equals("reject")){
out.println("<input type='button' value='delete' onclick='deletecompany(id)'/>");
}
%>
</body>
</html>这是我的代码
就是两种按钮点击都没响应,也没报错,试了几种fuction里的参数格式,都没用,求教

一般<a>标签中会使用href和onclick两种方式来进行进行页面跳转或执行动作,但是一般都会使用onclick来进行执行Ajax函数进行跳转,并同时使用onclick="xxxxxx(this)"来传递动态参数:例子如下

JSP代码如下:

Js代码如下:

一般会将href写为“javascript:void(0)” 而不是“#”,因为可以防止不必要的页面跳动;

而this指的就是a标签这个对象

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答