AJAX
[ class tree: AJAX ] [ index: AJAX ] [ all elements ]

Source for file form.php

Documentation is available at form.php

  1. <?php
  2. /**
  3.  * AJAX form submission example
  4.  *
  5.  * @category   HTML
  6.  * @package    AJAX
  7.  * @author     Arpad Ray <arpad@php.net>
  8.  * @author     Laurent Yaish <laurenty@gmail.com>
  9.  * @copyright  2005 Arpad Ray
  10.  * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
  11.  * @version    Release: 0.5.4
  12.  * @link       http://pear.php.net/package/HTML_AJAX
  13.  */
  14.  
  15.  
  16. ?>
  17. <html>
  18.     <head>
  19.         <script type="text/javascript" src="server.php?client=all&stub=test"></script>
  20.     </head>
  21.     <body>
  22.         <pre id="target">
  23.         </pre>
  24.     <form action="server.php" method="post" onsubmit="return !HTML_AJAX.formSubmit(this, 'target', {className: 'test', methodName:'multiarg'});">
  25.         <table>
  26.             <tr>
  27.                 <td>Text</td>
  28.                 <td><input type="text" name="test_text" value="example" /></td>
  29.             </tr>
  30.             <tr>
  31.                 <td>Single Select</td>
  32.                 <td>
  33.                     <select name="test_select">
  34.                                 <option value="example1">Example 1</option>
  35.                                 <option value="example2">Example 2</option>
  36.                     </select>
  37.                 </td>
  38.             </tr>
  39.             <tr>
  40.                 <td>Multi Select</td>
  41.                 <td>
  42.                     <select name="test_select_multiple[]" multiple="multiple">
  43.                         <option value="examplea">Example A</option>
  44.                         <option value="exampleb">Example B</option>
  45.                         <option value="examplec">Example C</option>
  46.                         <option value="exampled">Example D</option>
  47.                     </select>
  48.                 </td>
  49.             </tr>
  50.             <tr>
  51.                 <td>Single Checkbox</td>
  52.                 <td><input type="checkbox" name="single_checkbox" value="single_check1" /></td>
  53.             </tr>
  54.             <tr>
  55.                 <td>Multi Checkboxes</td>
  56.                 <td>
  57.                     <input type="checkbox" name="multi_checkbox[]" value="multi_check1" />1
  58.                     <input type="checkbox" name="multi_checkbox[]" value="multi_check2" />2
  59.                     <input type="checkbox" name="multi_checkbox[]" value="multi_check3" />3
  60.                 </td>
  61.             </tr>
  62.             <tr>
  63.                 <td>Radio Buttons</td>
  64.                 <td>
  65.                     <input type="radio" name="test_radio" value="radio_1" />1
  66.                     <input type="radio" name="test_radio" value="radio_2" />2
  67.                     <input type="radio" name="test_radio" value="radio_3" />3
  68.                 </td>
  69.             </tr>
  70.             <tr>
  71.                 <td>Textarea</td>
  72.                 <td>
  73.                     <textarea name="long_text">type a long string in here....</textarea>
  74.                 </td>
  75.             </tr>
  76.         </table>
  77.         <input type="submit" name="submit" value="Submit form" />
  78.         </form>
  79.  
  80.     <h3>JavaScript callback function target test</h3>
  81.     <form action="server.php" method="post" onsubmit="return !HTML_AJAX.formSubmit(this, function(result) { document.getElementById('target').innerHTML = result; }, {className: 'test', methodName:'multiarg'});">
  82.  
  83.         <table>
  84.             <tr>
  85.                 <td>Text</td>
  86.                 <td><input type="text" name="test_text" value="example" /></td>
  87.             </tr>
  88.         </table>
  89.     </form>
  90.     </body>
  91. </html>

Documentation generated on Fri, 04 Apr 2008 18:30:14 -0400 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.