js implements a tag hyperlinks to submit form forms

  • 2020-06-19 09:44:56
  • OfStack

This article illustrates how js implements a tag hyperlinks to submit form forms. Share to everybody for everybody reference. Specific implementation methods are as follows:


<form action="/home/search" method="get" id="search_form">
<div class="searchBox png" id="searchBox">
<input type="text" id="searchTxt" class="searchTxt"
name="shopName" value="@shopName">
<a class="searchPic h-submitBtn png"
id="h-submitBtn" onclick="document:search_form.submit();">
</a>
</div>
</form>

a tags can be written in the following ways:

Method 1:

<a class="searchPic h-submitBtn png" id="h-submitBtn"  onclick="document:search_form.submit();"> submit </a>

Method 2:

<a href="javascript:document:search_form.submit();"> submit </a>

Method 3:

<a class="searchPic h-submitBtn png" id="h-submitBtn"  onclick="document.getElementById('search_form').submit();"> submit </a>

I hope this article has been helpful for your javascript programming.


Related articles: