-2
这里是我的代码:如何在JavaScript函数中传递字符串变量?
JSP:
String userId = rs.getString("user_id");
<center><a href="#" onclick="edit(\'' + userId + '\');">Edit</a></center>
Javascrpt:
function edit(id)
{
alert(" user id is "+id);
}
,但它不工作。
提示错误:
Uncaught SyntaxError: Unexpected token ILLEGAL
可能重复的[从JavaScript读取的JSP变量(http://stackoverflow.com/questions/4803906/reading-a-jsp-variable-from-javascript ) – Surya 2014-11-08 10:41:16
这是你试过编码吗?没有人会明白什么是实际问题。请发布一个代码,这里的每个人都可以了解什么是在这里调查 – 2014-11-08 10:41:51
试试这个: