PHP Classes

Populando combo e Documentação

Recommend this page to a friend!

      pAjax  >  All threads  >  Populando combo e Documentação  >  (Un) Subscribe thread alerts  
Subject:Populando combo e Documentação
Summary:Populando combo e Documentação
Messages:2
Author:Leandro D Soares
Date:2006-02-01 16:04:29
Update:2006-02-24 17:42:13
 

  1. Populando combo e Documentação   Reply   Report abuse  
Picture of Leandro D Soares Leandro D Soares - 2006-02-01 16:04:29
Amigo,

Na verdade são três perguntas...

Primeiro: Você poderia dar um exemplo de como popular combos?

Segundo: Você teria a documentação em português brasil?

Terceiro: Ande consigo mais exemplos de utilização de sua classe?

Muito obrigado e desculpe-me por alongar...


  2. Re: Populando combo e Documentação   Reply   Report abuse  
Picture of Guilherme Blanco Guilherme Blanco - 2006-02-24 17:42:13 - In reply to message 1 from Leandro D Soares
### Translating your questions ###
Friend,
I have 3 questions...
First: Could you provide an example of how to populate combos?
Second: Do you have the documentation in Portuguese Brazilian?
Third: Where do I find more examples of your class usage?
Thanks and sorry for being so long...
##################################

##### Resposta em Português ######
Primeira: Claro, o exemplo está no final desta resposta.
Segunda: Não escrevi a documentação em Português, mas se alguém estiver disposto... =)
Terceira: Nem eu sei. Possuo as aplicações que desenvolvi, mas são para intranet e não têm como serem divulgadas.
#################################

####### Reply in English ########
First: Of course, the example is in the end of this reply.
Second: I did not write the documentation in Portuguese, but if anyone want to do it... =)
Third: I don't know too. I have the application I developed, but all are for intranet and can't be published.
#################################



## Example of Combo Population ##

<?php

require_once "CLASS/class.pAjax.php";

mysql_connect("localhost", "username", "password");
mysql_select_db("test");

function populateList() {
$resultset = mysql_query("SELECT id, nome FROM usuarios") or die("ERROR in SELECT Statement");

$result = array();

while($row = mysql_fetch_array($resultset)) {
$result[] = $row;
}

return $result;
}

$AJAX = new pAjax();
$AJAX->disableDomainProtection();
$AJAX->enableExportProtection();

$AJAX->export("populateList");
$AJAX->handleRequest("UTF-8");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.prg/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />

<title>pAjax Combo Population Test</title>

<script type="text/javascript" src="SOURCES/js/pajax-commom.js"></script>
<script type="text/javascript" src="SOURCES/js/pajax-parser.js"></script>
<script type="text/javascript" src="SOURCES/js/pajax-core.js"></script>

<script type="text/javascript">
function ComboPopulation() {
pAjax.call(this);
//pAjax.setDebugMode(true);
}

var _p = ComboPopulation.prototype = new pAjax;

_p.populate = function () {
var req = this.prepare("populateList", pAjaxRequest.GET);
req.async();
}

_p.onLoad = function () {
var el = document.getElementById("test_combo");
var data = this.getResponse();
var elItem;

for (var i = 0; i < data.length; i++) {
elItem = document.createElement("OPTION");
elItem.value = data[i][0];
elItem.innerHTML = data[i][1];

el.appendChild(elItem);
elItem = null;
}
}


window.onload = function () {
var o = new ComboPopulation();
o.populate();
}
</script>
</head>

<body>
<select id="test_combo" name="test_combo">
</select>
</body>
</html>