figure_ed_screen_najax.php

来自「Ajax最流行书籍」· PHP 代码 · 共 102 行

PHP
102
字号
<?php// START: najax_initdefine('NAJAX_BASE', 'najax');require_once('najax/najax.php');require_once('zipService.najax.php');NAJAX_Server::allowClasses('ZipService');if (NAJAX_Server::runServer()) {  exit;}// END: najax_init?><html>    <head>        <title>Customer Data Screen</title><!-- START: header --><?= NAJAX_Utilities::header('najax') ?><!-- END: header -->	<script type="text/javascript"><!-- START: register -->	var obj = <?= NAJAX_Client::register(new ZipService()) ?>;<!-- END: register --><!-- START: error -->	obj.onGet_city_stateError = function(error) {	  document.getElementById("zipError").innerHTML =                 "Error: " + error.message;	  return true;	}<!-- END: error --><!-- START: getZipData -->	function getZipData(zipCode) {	  obj.get_city_state(zipCode, assignCityAndState);	}<!-- END: getZipData --><!-- START: assignCityAndState -->	function assignCityAndState(data) {	  if (data.indexOf(',') > 0) {	    var cityState = data.split(',');	    document.getElementById("city").value = cityState[0];	    document.getElementById("state").value = cityState[1];	    document.getElementById("zipError").innerHTML = "";	  } else {	    document.getElementById("zipError").innerHTML = "Error: " + data;	  }	}<!-- END: assignCityAndState -->	</script>        <style type="text/css">            th { text-align: left; }        </style>    </head>    <body>        <h1>Corporate CRM System</h1>        <h2>Enter Customer Data</h2>        <table>            <tr>                <th>Customer Name:</th>                <td><input type="text" name="name"/></td>            </tr>            <tr>                <th>Address:</th>                <td><input type="text" name="address"/></td>            </tr>            <tr>                <th>Zip:</th>                <td><input onblur="getZipData(this.value)" type="text" name="zip" size="10" maxlength="10"/></td>                <td id="zipError" style="color: red"></td>            </tr>            <tr>                <th>City:</th>                <td><input id="city" type="text" name="city" autocomplete="off" /></td>            </tr>            <tr>                <th>State:</th>                <td><input id="state" type="text" name="state" size="3" maxlength="2" autocomplete="off" /></td>            </tr>            <tr>                <th></th>                <td><input type="Submit" value="Add Customer"/></td>            </tr>        </table>    </body></html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?