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
将参数传递给<;html:link>;来自javascript DEMO_Javascript_Jsp_Struts 1 - Fatal编程技术网

将参数传递给<;html:link>;来自javascript DEMO

将参数传递给<;html:link>;来自javascript DEMO,javascript,jsp,struts-1,Javascript,Jsp,Struts 1,如何从javascript传递val1和val2?将styleId=“myLink”添加到以使用javascript查询元素。 然后可以在JS中执行以下操作: <html:link href="DemoAction.do?method=val1&param1=val2">DEMO</html:link> var val1 = "newval1", val2 = "newval2"; // Option 1: Set the href attribute reg

如何从javascript传递val1和val2?

styleId=“myLink”
添加到
以使用javascript查询元素。
然后可以在JS中执行以下操作:

<html:link href="DemoAction.do?method=val1&param1=val2">DEMO</html:link>
var val1 = "newval1", val2 = "newval2";

// Option 1: Set the href attribute regardless of its current value
var link = document.getElementById("myLink");
link.setAttribute("href", "DemoAction.do?method="+val1+"&param1="+val2);

// Option 2: Set the href attribute depending on its current value
var link = document.getElementById("myLink"),
    hrefParts = link.getAttribute("href").split("?");
link.setAttribute("href", hrefParts[0]+"?method="+val1+"&param1="+val2);