I'm trying to submit a form through JavaScript that form ing dynamically from Google API.
The form doesn't having name. But it having class name.my
. The problem is I want to submit that form use it's class name.
<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" autoplete="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">
</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=".png" class="gsc-branding-img">
</td>
</tr>
</tbody>
</table>
</form>
I'm trying to submit a form through JavaScript that form ing dynamically from Google API.
The form doesn't having name. But it having class name.my
. The problem is I want to submit that form use it's class name.
<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" autoplete="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">
</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./uds/css/small-logo.png" class="gsc-branding-img">
</td>
</tr>
</tbody>
</table>
</form>
Share
Improve this question
edited Dec 16, 2015 at 12:49
Remi Guan
22.3k17 gold badges67 silver badges89 bronze badges
asked Jan 5, 2012 at 7:18
Vinoth KumarVinoth Kumar
931 gold badge1 silver badge8 bronze badges
1 Answer
Reset to default 4What you need to do is get the form and call its submit()
method, like this:
document.getElementsByClassName("gsc-search-box")[0].submit();
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742297420a4417403.html
评论列表(0条)