The rewritten title is: Use buttons outside the <form> tag to submit the form
P粉141911244
P粉141911244 2023-08-21 16:26:37
0
2
391
<p>Translation result:</p> <pre class="brush:php;toolbar:false;"><p>Suppose I have the following: <code><form method="get" action="something.php"> <input type="text" name="name" /> </form> <input type="submit" /></code></pre> <code> <p>How do I submit this form using a submit button located outside the form? I know there is a submit action attribute in HTML5, but I'm not sure if it's fully cross-browser compatible. If not, is there any other way to achieve this functionality? </p></code>
P粉141911244
P粉141911244

reply all(2)
P粉432906880

In HTML5, there is form attribute. basically

<form id="myform" method="get" action="something.php">
    <input type="text" name="name" />
</form>

<input type="submit" form="myform" value="Update"/>
P粉018548441

Update: In modern browsers, you can use the form attribute to achieve this .


As far as I know, you can't achieve this functionality without using JavaScript.

This is the description in the specification

This is the part I bolded

submitButtons are considered controls.

http://www.w3.org/TR/html4/interact/forms.html#h-17.2.1

Based on comments

Why not put the input inside the form, but use CSS to place it elsewhere on the page?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!