簡體   English   中英

td標簽內的javascript onclick

[英]javascript onclick inside td tag

我想提交一個帶有<table><form> 如何使用默認操作提交該<form> 使用<select>標記,我可以使用onchange javascript函數提交表單。 我以為<td>標記內的onclick="this.form.submit"可以解決,但螢火蟲指示錯誤: 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>

this對象你指的是在onclick功能是點擊td ,而不是整個文件。 您可能要改用此方法:

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

但是確實,您最好改用ID來引用表單。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM