Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用该表单类名在JavaScript中提交表单?_Javascript - Fatal编程技术网

如何使用该表单类名在JavaScript中提交表单?

如何使用该表单类名在JavaScript中提交表单?,javascript,Javascript,我正试图通过JavaScript提交一个表单,该表单动态来自GoogleAPI 表单没有名称。但是它有classname.my。问题是我想用它的类名提交表单 <form class="gsc-search-box" accept-charset="utf-8"> <table cellspacing="0" cellpadding="0" class="gsc-search-box"> <tbody> <tr> <td

我正试图通过JavaScript提交一个表单,该表单动态来自GoogleAPI

表单没有名称。但是它有class
name.my
。问题是我想用它的类名提交表单

<form class="gsc-search-box" accept-charset="utf-8">
<table cellspacing="0" cellpadding="0" class="gsc-search-box">
<tbody>
    <tr>
       <td class="gsc-input">
       <input type="text" autocomplete="off" size="10" class=" gsc-input" name="search" title="search" style="background: none repeat scroll 0% 0% rgb(255, 255, 255);" dir="ltr">
       </td>
       <td class="gsc-search-button">
       <input type="submit" value="Search" class="gsc-search-button" title="search">
       </td>
       <td class="gsc-clear-button">
         <div class="gsc-clear-button" title="clear results">
          &nbsp;
         </div>
       </td>
    </tr>
  </tbody>
  </table>
  <table cellspacing="0" cellpadding="0" class="gsc-branding">
     <tbody>
         <tr>
           <td class="gsc-branding-user-defined">
           </td>
           <td class="gsc-branding-text">
           <div class="gsc-branding-text">
                powered by
            </div>
            </td>
            <td class="gsc-branding-img">
            <img src="http://www.google.com/uds/css/small-logo.png" class="gsc-branding-img">
            </td>
          </tr>
       </tbody>
     </table>
   </form>

技术支持

您需要做的是获取表单并调用其
submit()
方法,如下所示:

document.getElementsByClassName("gsc-search-box")[0].submit();

您需要做的是获取表单并调用其
submit()
方法,如下所示:

document.getElementsByClassName("gsc-search-box")[0].submit();

如果所需表单是此类页面上的第一个元素。是否有方法使用类名跟踪一个页面上的所有表单?如果所需表单是此类页面上的第一个元素。是否有方法使用类名跟踪一个页面上的所有表单?