我制作了一个HTML表单,在我的网站上添加了一位朋友,我希望能够通过我提供的链接提交它。我试图做> dput (sour)
structure(list(sequence = c("<{\"OV188\"}>", "<{\"OV191\"}>",
"<{\"OV194\"}>", "<{\"OV195\"}>", "<{\"OV197\"}>", "<{\"OV200\"}>",
"<{\"OV188\"},{\"OV200\"}>", "<{\"OV191\"},{\"OV197\"}>", "<{\"OV194\"},{\"OV197\"}>",
"<{\"OV195\"},{\"OV197\"}>", "<{\"OV194\"},{\"OV195\"},{\"OV197\"}>",
"<{\"OV191\"},{\"OV195\"},{\"OV197\"}>", "<{\"OV191\"},{\"OV194\"},{\"OV195\"},{\"OV197\"}>",
"<{\"OV191\"},{\"OV194\"},{\"OV197\"}>", "<{\"OV191\"},{\"OV195\"}>",
"<{\"OV194\"},{\"OV195\"}>", "<{\"OV191\"},{\"OV194\"},{\"OV195\"}>",
"<{\"OV191\"},{\"OV194\"}>"), support = c(0.628465804066543,
0.584103512014787, 0.584103512014787, 0.680221811460259, 0.584103512014787,
0.56007393715342, 0.56007393715342, 0.584103512014787, 0.584103512014787,
0.584103512014787, 0.584103512014787, 0.584103512014787, 0.584103512014787,
0.584103512014787, 0.584103512014787, 0.584103512014787, 0.584103512014787,
0.584103512014787)), .Names = c("sequence", "support"), class = "data.frame", row.names = c("1",
"2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
"14", "15", "16", "17", "18"))
但是没有用。
onClick="form.submit();"
答案 0 :(得分:1)
问题是form
在任何地方都没有被定义为javascript变量。您可以为<form>
标记添加&#34; myFormName&#34;等名称,然后使用document.myFormName
从DOM中获取该名称。获得表单的DOM元素后,然后就可以在其上调用submit()
。
我还应该提一下,将javascript内联到标签中通常被认为是不好的做法。你可以做到,但它并不理想。相反,您应该将其添加到<script>
标记或单独的.js文件中。
<head>
<script>
document.getElementById('mySubmitLink').onclick = function() {
document.getElementById('myForm').submit();
}
</script>
</head>
<body>
...
<form id="myForm" method="post">
<input type="text" name="friendname"/>
<br/>
<a href="http://site/AddFriendPHP.php" id="mySubmitLink"><div class="FriendRequestSend-Button">Send</div></a>
</form>
答案 1 :(得分:0)
请参阅:How to submit a form using javascript?
所以基本上给你一个这样的名字:
<form method="post" name="theForm">...</form>
并为javascript执行类似的操作:
document.theFormName.submit();
(所以链接会是这样的:
<a href="http://site/AddFriendPHP.php" onclick="document.theFormName.submit();"><div class="FriendRequestSend-Button">Send</div></a>
答案 2 :(得分:-1)
我建议使用
export abstract class DataService<T> {
static $inject = ['$resource'];
private svc: ng.resource.IResourceClass<ng.resource.IResource<T>>;
constructor(
protected $resource: ng.resource.IResourceService, url: string
) {
this.svc = <ng.resource.IResourceClass<ng.resource.IResource<T>>>this.$resource(url, { id: '@id' });
}
public get(id: number): ng.IPromise<T> {
return this.svc.get({ id: id }).$promise;
}
}
export class MyDataService
extends DataService<IItem> {
// big problem here!!!
constructor(
) {
super("/api/items/:id");
}
}