Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/431.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
如何在Javascript函数中传递字符串变量?_Java_Javascript_Jsp - Fatal编程技术网

如何在Javascript函数中传递字符串变量?

如何在Javascript函数中传递字符串变量?,java,javascript,jsp,Java,Javascript,Jsp,这是我的密码: JSP: 但它不起作用 它给出了错误: 未捕获的语法错误:意外标记非法 你需要这样做 var userId = '${userId}' <-- with ${} you get the var. 致以最诚挚的问候。朋友们,请使用此代码 <center><a href="#" onclick="edit( <%=userId %> ;">Edit</a></center> 您试图编写的代码是否可能与此重

这是我的密码:

JSP:

但它不起作用

它给出了错误:

未捕获的语法错误:意外标记非法

你需要这样做

var userId = '${userId}'   <-- with ${} you get the var.

致以最诚挚的问候。

朋友们,请使用此代码

<center><a href="#"  onclick="edit(  <%=userId %>  ;">Edit</a></center>

您试图编写的代码是否可能与此重复??没有人会明白实际的问题是什么。请发布一个代码,让这里的每个人都能理解这里的问题。试试这个:谢谢艾米。现在它可以工作了。
var userId = '${userId}'   <-- with ${} you get the var.
... onclick="edit('userId')" ...


function edit(userId) {
    var id = rs.getString(userId);
    alert('id is: ' + id);
}
<center><a href="#"  onclick="edit(  <%=userId %>  ;">Edit</a></center>