我想在其中提交<form>
和<table>
。如何使用默認操作提交<form>
?使用<select>
標籤,我可以使用onchange
javascript函數提交表單。我認爲onclick="this.form.submit"
裏面的<td>
標籤會解決,但螢火蟲表示有錯誤:TypeError: this.form is undefined
內嵌td標記的javascript onlick
有什麼不對?你指的是在的onclick功能
<div class="report">
<form method="post" name="status_students">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="tdreport">Active</td>
<td class="tdreport">Unstable</td>
<td class="tdreport">Inactive</td>
</tr>
<tr>
<td class="active" name="students_actives" value="actives" onclick="this.form.submit()">
<?php
if ($this->siteCenterSelected == "All") {
echo count($this->usersStatus['verde']);
} else {
echo count($this->usersStatusSiteCenter['verde']);
}
?>
</td>
<td class="unstable"><?php
if ($this->siteCenterSelected == "All") {
echo count($this->usersStatus['amarelo']);
} else {
echo count($this->usersStatusSiteCenter['amarelo']);
}
?>
</td>
<td class="inactive"><?php
if ($this->siteCenterSelected == "All") {
echo count($this->usersStatus['vermelho']);
} else {
echo count($this->usersStatusSiteCenter['vermelho']);
}
?>
</td>
</tr>
</table>
</form>
</div>
在你的場景中'this'是指td元素,一個骯髒的解決方案是使用'.parent' - >'this.parent.parent.parent'在dom中提升。你也可以通過他的名字找到你的表格。 'document.status_students' – Cyrbil
嘗試'document.status_students.submit()'! –