Envio De Variables
![]() ![]() ![]() |
Envio De Variables
| SuNcO |
Jun 23 2008, 03:55 AM
Post
#1
|
|
Administrador ![]() ![]() ![]() ![]() ![]() Group: Admin Posts: 624 Joined: 21-October 05 Member No.: 1 |
En este ejemplo puedes enviar variables para hacer una busqueda. El ejemplo es sumamente sencillo, ovbiamente seguro lo utilizarias con MySQL
El ejemplo terminado puede verse aqui Tienes que cambiar el url de CodigoPlus a tu propio servidor, de lo contrario te marcara error por crossdomain (por seguridad un sitio no puede llamar a otro) CODE <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" color="#000000" height="311" width="348" verticalAlign="middle" horizontalAlign="center" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFE, #FFFFFF]" borderStyle="solid"> <mx:Script> <![CDATA[ import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; import mx.controls.Alert; [Bindable] private var datos:XMLList; public function handleXML(event:ResultEvent):void { datos = event.result.option as XMLList; } public function handleFault(event:FaultEvent):void { Alert.show(event.fault.faultString, "Error"); } ]]> </mx:Script> <mx:HTTPService result="handleXML(event);" fault="handleFault(event);" id="xmlRPC" resultFormat="e4x" url="http://www.codigoplus.com/ejemplos/flex/ejemplo2/datos2.php"> <mx:request> <tel>{tel_txt.text}</tel> <nom>{nom_txt.text}</nom> </mx:request> </mx:HTTPService> <mx:Label x="47" y="32" text="Telefono" width="55" height="18" fontWeight="bold"/> <mx:Label x="47" y="60" text="Nombre" width="55" height="18" fontWeight="bold"/> <mx:TextInput x="110" y="30" id="tel_txt" width="160" height="22"/> <mx:TextInput x="110" y="56" id="nom_txt" width="160" height="22"/> <mx:Button x="134" y="98" label="Buscar datos" click="xmlRPC.send();" width="99" height="22"/> <mx:DataGrid dataProvider="{datos}" x="47" y="141" width="262" height="136" editable="false"> <mx:columns> <mx:DataGridColumn headerText="Telefono" dataField="tel" width="100" /> <mx:DataGridColumn headerText="Nombre" dataField="nom" /> </mx:columns> </mx:DataGrid> </mx:Application> El archivo Php debe llamarse datos.php CODE <? $Telefonos = array("6699851233","6699801435","6691536765","669153201","6699835400"); $Nombres = array("Jorge Estrada","Raul Montes","Jaime Lizarraga","Andres Lopez","Carlos Sanchez"); $resultado[] = "<options>"; for ($i = 0; $i < count($Telefonos); $i ++) { $agregar = "no"; if ($_GET["tel"]) { if (strpos("-".$Telefonos[$i],$_GET["tel"]) > 0) { $agregar = "si"; } } else { if (strpos("-".$Nombres[$i],$_GET["nom"]) > 0) { $agregar = "si"; } } if ($agregar == "si") { $resultado[] = "<option>"; $resultado[] = "<tel>".$Telefonos[$i]."</tel>"; $resultado[] = "<nom>".$Nombres[$i]."</nom>"; $resultado[] = "</option>"; } } $resultado[] = "</options>"; print implode("\n", $resultado); ?> |
![]() ![]() ![]() |
| Lo-Fi Version | Time is now: 22nd November 2008 - 02:17 AM |