我在XQuery文件中创建了一个HTML按钮。我只是想知道当我点击它时如何调用我文件的XQuery函数?
xquery version "1.0";
declare option exist:serialize "method=xhtml media-type=text/html";
declare function local:fn($str as xs:string) as xs:string
{
...
};
<html>
...
<input type="submit" onclick=" ? "/>
</html>
我试过了:
<input type="submit" value="Search" onclick="{local:fn()}"/>
但没效果。
答案 0 :(得分:1)
您可以在http://www.xqib.org/js/OnClickEvent.html
找到示例<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XQIB: Sample page</title>
<meta charset="UTF-8"/>
<script type="text/javascript" src="mxqueryjs/mxqueryjs.nocache.js"></script>
<script type="application/xquery">
declare sequential function local:listener($loc, $evtObj) {
b:alert("Hello, World")
};
b:addEventListener
(b:dom()//input[@id="myButton"], "onclick", local:listener#2)
</script>
</head>
<body>
<h1>Onclick Event</h1>
<input id="myButton" type="button" value="Click me"/>
</body>
</html>