Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.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
Html 是否可以覆盖表单中的操作值?_Html_Forms - Fatal编程技术网

Html 是否可以覆盖表单中的操作值?

Html 是否可以覆盖表单中的操作值?,html,forms,Html,Forms,提交第二个searchfield的值时,是否可以覆盖一个searchfield的操作值? 我需要添加一个搜索字段 <input type="search" id="id2"> <input type="submit" value="value2" /> 至: 通过在第二个searchfield中按enter键,我被转发到第一个searchfield的链接,因为它有一

提交第二个searchfield的值时,是否可以覆盖一个searchfield的操作值? 我需要添加一个搜索字段

      <input type="search" id="id2">
      <input type="submit" value="value2" />
至:


通过在第二个searchfield中按enter键,我被转发到第一个searchfield的链接,因为它有一个action值

我可以更改此行为吗?

使用JavaScript:

    function setAction(){ 
        document.getElementById('search').setAttribute('action',document.getElementById('id2').value
    }

您需要使用setAction()设置“id2”的onClick事件。

您的意思是当您单击value2时。。。是否要将表单的操作参数设置为id2中的值?
    function setAction(){ 
        document.getElementById('search').setAttribute('action',document.getElementById('id2').value
    }