Location: PHPKode > projects > PhpWAFr - PHP Web Application Framework > phpwafr-1.1.2/content/object_combo.php
<?php
/**
 * object_combo.php ::  Processamento para atualizar campos do object_edit durante a digitação,
 * 						por exemplo, ao digitar o cep, este script pode ser chamado para buscar o
 *						bairro, cidade, logradouro e estado.
 *
 * PHP version 4
 *
 * phpWAFr version 1.1.2
 * copyright (c) 2007 Associação SoftwareLivre.org
 *
 * phpWAFr is an open source PHP library designed to accelerate
 * the development of transactional database Web applications.
 *
 * phpWAFr is released under the terms of the LGPL license 2.1
 * http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html  LGPL License 2.1
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * @package    phpWAFr
 * @version    1.1.2
 * @author     Marcelo Rezende <hide@address.com>
 * @copyright  copyright (c) 2007 Associação SoftwareLivre.org
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html  LGPL License 2.1
 */ 

require_once("../inc/common.php");

/*
	estabelece conexão com o banco de dados
*/
$conn = new db();
$conn->open();

/*
	captura a variável passada pela função do frame content (get)
*/
$search = getParam("search");

/*
	seleção dos registros
*/
$sql = "SELECT * FROM cep WHERE cod_cep='$search'";
$rs = new query($conn,$sql);
?>

<html>
<script language="JavaScript" type="text/javascript">
<!--
/*
	Exemplo de função que atualiza um campo listbox no formulário do frame content
*/
function initiate() {
	ind = parent.content.document.frm.f_field.length;
	while (parent.content.document.frm.f_field.length > 0) {
		parent.content.document.frm.f_field.options[0] = null;
	}
	<?php
	$r = 0;
	while ($rs->getrow()) {
		$logradouro    = $rs->field("logradouro");
		$logradouro_id = $rs->field("logradouro_id");
		echo "parent.content.document.frm.f_field.options[$r] = new Option(\"$logradouro\",\"$logradouro_id\",true,false);\n";
		$r++;
	}
	?>
}
//-->
</script>

<body onLoad=initiate();>
</body>
</html>
Return current item: PhpWAFr - PHP Web Application Framework