如何通过点击链接使用JavaScript提交表单?

问题描述:

你好,

我想要通过clink link s来检查java脚本的功能

Plz帮帮我......... ..

谢谢



我的尝试:



1.< form name =myformaction =index.php>

2.搜索:< input type ='text'name ='query'/>

3. 搜索

4.< / form>

5.< script type =text / javascript>

6.函数submitform()

7. {

8. document,myform,submit();

9.}

10.< / script>

Hello,
I wanted to incorporate the function that will check the java script by clinking link s
Plz help me out...........
Thanks

What I have tried:

1. <form name="myform" action="index.php">
2. Search: <input type='text' name='query' />
3. Search
4. </form>
5. <script type="text/javascript">
6. function submitform()
7. {
8. document,myform,submit();
9. }
10. </script>

试试这个



try this

<!DOCTYPE html>
<html>
<body>
    <form id="myform" action="index.php">
        Search: <input type='text' name='query' />
        <a href="#" onclick="submitform()">Search</a>
    </form>
    <script>
        function submitform() {
            document.getElementById("myform").submit();
        }
    </script>

</body>
</html>