Jump to content

input tags outside form tags


niche

Recommended Posts

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>

Link to comment
Share on other sites

<form id="theform" 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 /></form><input type="button" value="Go" onclick="go()" /><!-- OR --><button onclick="go()">Go</button><script type="text/javascript">function go (){document.getElementById('theform').submit();}</script>

Link to comment
Share on other sites

Nothing incorrect about that solution, but it does change one of the essential features of a form: a normal form always works; it does not require JavaScript to work.Are you asking this question because you are experiencing layout difficulties when the submit button is inside the form?A form is a block-level element with no inherent style features. You can wrap virtually all your page content inside form tags and not observe a physical difference. In this way it would be possible to contain any number of form elements and a submit button within one set of form tags, regardless of their physical position.I would think very hard about disrupting the normal behavior of a form simply for the sake of a layout decision (if in fact that is what prompted this thread).

Link to comment
Share on other sites

Thanks for the help from wirehopper and Deirdre's Dad. It was a layout decision that prompted my question that I'll abandon due to DD's advice. Thanks Again,Niche

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...