formSubmissionTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. require_once("../xajax.inc.php");
  3. function testForm($formData)
  4. {
  5. $objResponse = new xajaxResponse();
  6. $objResponse->addAlert("formData: " . print_r($formData, true));
  7. $objResponse->addAssign("submittedDiv", "innerHTML", nl2br(print_r($formData, true)));
  8. return $objResponse->getXML();
  9. }
  10. $xajax = new xajax();
  11. //$xajax->debugOn();
  12. $xajax->registerFunction("testForm");
  13. $xajax->processRequests();
  14. ?>
  15. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  16. "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
  17. <html xmlns="http://www.w3.org/1999/xhtml">
  18. <head>
  19. <title>Form Submission Test| xajax Tests</title>
  20. <style type="text/css">
  21. fieldset > div
  22. {
  23. border: 1px solid gray;
  24. padding: 5px;
  25. background-color: white;
  26. }
  27. </style>
  28. <?php $xajax->printJavascript("../") ?>
  29. </head>
  30. <body>
  31. <h2><a href="index.php">xajax Tests</a></h2>
  32. <h1>Form Submission Test</h1>
  33. <div>
  34. <form id="testForm1" onsubmit="return false;">
  35. <fieldset style="display:inline; background-color: rgb(230,230,230);">
  36. <legend>Test Form</legend>
  37. <div style="margin: 3px;">
  38. <div>Text Input</div>
  39. <input type="text" id="textInput" name="textInput" value="text" />
  40. </div>
  41. <div style="margin: 3px;">
  42. <div>Password Input</div>
  43. <input type="password" id="textInput" name="passwordInput" value="2br!2b" />
  44. </div>
  45. <div style="margin: 3px;">
  46. <div>Textarea</div>
  47. <textarea id="textarea" name="textarea">text text</textarea>
  48. </div>
  49. <div style="margin: 3px;">
  50. <div>
  51. <input type="checkbox" id="checkboxInput1" name="checkboxInput[]" value="true" checked="checked" />
  52. <label for="checkboxInput1">Checkbox Input 1</label>
  53. </div>
  54. <div>
  55. <input type="checkbox" id="checkboxInput2" name="checkboxInput[]" value="true" checked="checked" />
  56. <label for="checkboxInput2">Checkbox Input 2</label>
  57. </div>
  58. </div>
  59. <div style="margin: 3px;">
  60. <div>Radio Input</div>
  61. <div>
  62. <input type="radio" id="radioInput1" name="radioInput" value="1" checked="checked" />
  63. <label for="radioInput1">One</label>
  64. </div>
  65. <div>
  66. <input type="radio" id="radioInput2" name="radioInput" value="2" />
  67. <label for="radioInput2">Two</label>
  68. </div>
  69. </div>
  70. <div style="margin: 3px;">
  71. <div>Select</div>
  72. <select id="select" name="select">
  73. <option value="1">One</option>
  74. <option value="2">Two</option>
  75. <option value="3">Three</option>
  76. <option value="4">Four</option>
  77. </select>
  78. </div>
  79. <div style="margin: 3px;">
  80. <div>Multiple Select</div>
  81. <select id="multipleSelect" name="multipleSelect[]" multiple="multiple" size=4>
  82. <option value="1" selected="selected">One</option>
  83. <option value="2">Two</option>
  84. <option value="3">Three</option>
  85. <option value="4">Four</option>
  86. </select>
  87. </div>
  88. <span style="margin: 3px;">
  89. <input type="submit" value="submit through xajax" onclick="xajax_testForm(xajax.getFormValues('testForm1')); return false;" />
  90. </span>
  91. </fieldset>
  92. </form>
  93. </div>
  94. <div id="submittedDiv" style=" margin: 3px;"></div>
  95. </body>
  96. </html>