<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: programmatically code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 27 Jul 2008 02:01:14 GMT</pubDate>
    <description>DZone Snippets: programmatically code</description>
    <item>
      <title>Submit Form programmatically from PHP using JavaScript</title>
      <link>http://snippets.dzone.com/posts/show/5154</link>
      <description>It&#180;s something quite easy but may help a newby (as I&#180;m now) in the future. &lt;br /&gt;This is a simple function in PHP to insert a JavaScript sentence which will do the same action as if the user would be pressing the Submit Button.&lt;br /&gt;It can be used to use any control as a Submit Button or in case you make a form you need to send without interaction from the user.&lt;br /&gt;the $FormName must be the name specified in the Form tag (i.e.: &lt;form action="MyActionURL" method="post" enctype="application/x-www-form-urlencoded" name="MyFormName"&gt;), if you didn&#180;t specified any, you must now :)&lt;br /&gt;Lastly, just a tip regarding a trouble I had and may be you case too... if you have a form with all hidden fields, it won&#180;t work, you have to have at least something echoed inside the form, just a letter can help, anyway, as it will redirect to the action URL, it should not be a problem as the form will disappear.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function SubmitForm($FormName)&lt;br /&gt;//JavaScript function to submit a form programmatically&lt;br /&gt;//$FormName must be form&#180;s name (as specified in the opening form tag)&lt;br /&gt;{&lt;br /&gt;	echo '&lt;script language="javascript"&gt;document.'.$FormName.'.submit()&lt;/script&gt;';&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 19 Feb 2008 20:23:28 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5154</guid>
      <author>dneuma (Daniel Neumann)</author>
    </item>
  </channel>
</rss>
