0

Is it possible to trigger the action of a form with a submit button that's outside the form tags? If so, how should this example be rescripted to make the input tag work outside the form tags?

<html>
<body>

<form name="input" action="html_form_action.asp" method="get">
First name: <input type="text" name="FirstName" value="Mickey" /><br />
Last name: <input type="text" name="LastName" value="Mouse" /><br />
<input type="submit" value="Submit" />
</form>


</body>
</html>

Edited by mike_2000_17: Fixed formatting

5
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by razvysb
0

Here is one example.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 25 March 2009), see www.w3.org">
    <title></title>
  </head>
  <body>
    <form name="myform" id="myform" action="html_form_action.asp" method="get">
      First name: <input type="text" name="FirstName" value="Mickey"><br>
      Last name: <input type="text" name="LastName" value="Mouse"><br>
    </form>
      <button onclick="myform.submit();" value="Submit">SUBMIT</button>
  </body>
</html>

A word of caution: using an HTML or javascript reserved word ('input') as an id or name is asking for trouble :(

Edited by fxm: n/a

0

Also you don't want to give an input within the form a name="submit", when calling the form's submit function as above, as it will get confused for the forms submit method. As a side note (in case it's not obvious) you can do the above example with any type of element that has an onclick event.

0

I have published an HTML site from my network drive in my office. I need to put a section where people can leave comments. I tried to read on that as I don't know much about HTML. Can someone help me creat a blog kinda stuff for my HTML site?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.