gpt4 book ai didi

td标签内的javascript onclick

转载 作者:行者123 更新时间:2023-11-28 00:13:58 24 4
gpt4 key购买 nike

我想提交<form><table>在里面。如何提交<form>使用默认操作?与<select>标签我可以使用 onchange 提交表单JavaScript 函数。我以为onclick="this.form.submit"里面<td>标签可以解决,但 firebug 指示错误:TypeError: this.form is undefined

出了什么问题?

<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>

最佳答案

您在 onclick 函数中引用的

this 对象是单击的 td,而不是整个文档。您可能想改用它:

onclick="document.forms[0].submit()"

但事实上,您最好通过 ID 来引用表单。

关于td标签内的javascript onclick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30626417/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com