Location: PHPKode > scripts > pAjax > pajax/tests/test_form.php
<?php

require "../class.pAjax.php";


function formTest() {
	return func_get_args();
}


$AJAX = new pAjax;
$AJAX->disableDomainProtection();
$AJAX->enableExportProtection();
$AJAX->export("formTest");
$AJAX->handleRequest();

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
	<head>
		<title>Form Attachment Test</title>
		<?php $AJAX->showJavaScript(".."); ?>
        <script type="text/javascript">
            function FormTest() {
				pAjax.call(this);
				pAjax.setDebugMode(true);
			}


			var _p = FormTest.prototype = new pAjax;

			_p.execAction = function () {
				var oRequest = this.prepare("formTest", pAjaxRequest.POST);

				// Attach a form via its ID or its NAME. 
				// Also, its OBJECT is supported.
				oRequest.setFormParam("f1");

				oRequest.execute(pAjaxRequest.SYNC); // Synchronized Mode Test
			}
			
			_p.onChange = function () {
                alert("Ready State: " + this.getReadyState());
            }
            
            _p.onError = function () {
            	var e = this.getError();
            	
            	if (typeof e == "string") {
            		alert(e);
				} else {
	            	for (var item in e) {
    	        		alert(item + " = " + e[item]);
					}
				}
			}

			_p.onLoad = function () {
			    var data = this.getResponse();
				
				for (var item in data) {
					if (typeof data[item] != "object") {
						alert('Content of data[' + item + '] = ' + data[item]);
					} else {
						for (var innerItem in data[item]) {
							alert('Content of data[' + item + '][' + innerItem + '] = ' + data[item][innerItem]);
						}
					}
				}
			}
		</script>
	</head>
	
	<body>
		<form name="f1">
			<label for="text1">Full Name:</label><br />
			<input type="text" name="text1" value="Guilherme Blanco" /><br />
			
			<label for="pwd1">Password</label><br />
			<input type="password" name="pwd1" value="MyPassword" /><br />
			
			<label for="chk1">Remember me?</label><br />
			<input type="checkbox" name="chk1" value="y" /><br />
			
            <label for="rad1">Login at:</label><br />
			<input type="radio" name="rad1" value="admin" checked="true" /> Admin CP<br />
			<input type="radio" name="rad1" value="moderator" /> Moderator CP<br />
            <input type="radio" name="rad1" value="personal" /> Personal CP<br />
            
            <label for="sel1">Select Mirror:</label><br />
            <select name="sel1">
            	<option value="BRA">Brazil</option>
            	<option value="ENG">England</option>
            	<option value="CAN">Canada</option>
                <option value="USA">United States</option>
            </select><br />

            <label for="sel2">Select Functionalities:</label><br />
            <select name="sel2" multiple="true" size="3">
            	<option value="permissions">Permissions Management</option>
            	<option value="groups">Groups Management</option>
            	<option value="users">Users Management</option>
            	<option value="categories">Categories Management</option>
            	<option value="articles">Articles Management</option>
            	<option value="comments">Comments Management</option>
            	<option value="forums">Forums Management</option>
            	<option value="subscriptions">Subscriptions Management</option>
                <option value="polls">Polls Management</option>
                <option value="stats">Statistics Management</option>
            </select><br />

            <br />
            <input type="button" name="send" value="Test!" onclick="(new FormTest()).execAction();" />
		</form>
	</body>
</html>
Return current item: pAjax