Foros del Web » Programando para Internet » PHP »

TextBox llenados por un combobox???

Estas en el tema de TextBox llenados por un combobox??? en el foro de PHP en Foros del Web. Hola Amigos, Estoy con un formulario de actualización de registros con php y tengo un combobox que muestra los nombres de Clientes de una tabla ...
  #1 (permalink)  
Antiguo 11/04/2005, 11:32
 
Fecha de Ingreso: agosto-2004
Ubicación: Stgo de Chile
Mensajes: 64
Antigüedad: 19 años, 8 meses
Puntos: 0
TextBox llenados por un combobox???

Hola Amigos,
Estoy con un formulario de actualización de registros con php y tengo un combobox que muestra los nombres de Clientes de una tabla llamada Clientes. Quisiera saber como llenar 12 textbox automaticamente con los registros correspondientes, al nombre que seleccionó el usuario.

Actualmente el cliente selecciona del combo, el nombre que quiere actualizar y todos los demás datos debe ingresarlos en forma manual a los 12 texbox, aunque solo se actualice un solo dato.

Alguien sabe como hacerlo??

Última edición por htmlPedrote; 12/04/2005 a las 08:33
  #2 (permalink)  
Antiguo 11/04/2005, 14:55
Avatar de lalogrosz  
Fecha de Ingreso: mayo-2002
Ubicación: Capital Federal
Mensajes: 339
Antigüedad: 21 años, 11 meses
Puntos: 6
Código HTML:
<script type="text/javascript">

        var suggestions = new Array("Alan Grosz | Velasco 127 11C | 4857-2470",
                                    "Alejandro Grosz | Humahuaca 3947 6-E ",
                                     "J.A VAN EEDEN | 22 BRILL ST | SASOLBURG | 0828155533 | [email][email protected][/email]",
                                     "B-3-4",
                                     "B-5-6");
        var outp;
        var oldins;
        var posi = -1;
        var words = new Array();
        var input;
        var key;

        function setVisible(visi){
                var x = document.getElementById("shadow");
                var t = document.getElementsByName("text")[0];
                x.style.position = 'absolute';
                x.style.top =  (findPosY(t)+3)+"px";
                x.style.left = (findPosX(t)+2)+"px";
                x.style.visibility = visi;
        }

        function init(){
                outp = document.getElementById("output");
                window.setInterval("lookAt()", 100);
                setVisible("hidden");
                document.onkeydown = keygetter; //needed for Opera...
                document.onkeyup = keyHandler;
        }

        function findPosX(obj)
        {
                var curleft = 0;
                if (obj.offsetParent){
                        while (obj.offsetParent){
                                curleft += obj.offsetLeft;
                                obj = obj.offsetParent;
                        }
                }
                else if (obj.x)
                        curleft += obj.x;
                return curleft;
        }

        function findPosY(obj)
        {
                var curtop = 0;
                if (obj.offsetParent){
                        curtop += obj.offsetHeight;
                        while (obj.offsetParent){
                                curtop += obj.offsetTop;
                                obj = obj.offsetParent;
                        }
                }
                else if (obj.y){
                        curtop += obj.y;
                        curtop += obj.height;
                }
                return curtop;
        }

        function lookAt(){
                var ins = document.getElementsByName("text")[0].value;
                var max = 0;
                var div = document.getElementById("output");

                if (oldins == ins) return;
                else if (posi > -1);
                else if (ins.length > 0){
                        words = getWord(ins);
                        if (words.length > 0){
                                clearOutput();
                                for (var i=0;i<words.length; ++i){
                                   addWord (words[i]);
                                   if(words[i].length > max)
                                      max = words[i].length
                                }

                                if((max * 6.6) > 400)
                                    max = 400
                                else
                                    max = max * 6.6;

                                div.style.width = max;
                                setVisible("visible");
                                input = document.getElementsByName("text")[0].value;
                        }
                        else{
                                setVisible("hidden");
                                posi = -1;
                        }
                }
                else{
                        setVisible("hidden");
                        posi = -1;
                }
                oldins = ins;
        }

        function addWord(word){
                var sp = document.createElement("div");
                sp.appendChild(document.createTextNode(word));
                sp.onmouseover = mouseHandler;
                sp.onmouseout = mouseHandlerOut;
                sp.onclick = mouseClick;
                outp.appendChild(sp);
        }

        function clearOutput(){
                while (outp.hasChildNodes()){
                        noten=outp.firstChild;
                        outp.removeChild(noten);
                }
                posi = -1;
        }

        function getWord(beginning){
                var words = new Array();
                for (var i=0;i<suggestions.length; ++i){
                        var j = -1;
                        var correct = 1;
                        while (correct == 1 && ++j < beginning.length){
                                
                                if ( (suggestions[i].charAt(j) != (beginning.charAt(j)).toUpperCase()) &&
                                     (suggestions[i].charAt(j) != (beginning.charAt(j)).toLowerCase()) )
                                     correct = 0;
                        }
                        if (correct == 1) words[words.length] = suggestions[i];
                }
                return words;
        }

        function setColor (_posi, _color, _forg){
                outp.childNodes[_posi].style.background = _color;
                outp.childNodes[_posi].style.color = _forg;
        }

        function keygetter(event){
                if (!event && window.event) event = window.event;
                if (event) key = event.keyCode;
                else key = event.which;
        }

        function keyHandler(event){
                if (document.getElementById("shadow").style.visibility == "visible"){
                var textfield = document.getElementsByName("text")[0];

                if (key == 40){ //Key down

                        if (words.length > 0 && posi < words.length-1){
                                if (posi >=0) setColor(posi, "orange", "black");
                                else input = textfield.value;
                                setColor(++posi, "blue", "white");
                                textfield.value = outp.childNodes[posi].firstChild.nodeValue;
                                llenar(outp.childNodes[posi].firstChild.nodeValue);

                        }
                }
                else if (key == 38){ //Key up
                        if (words.length > 0 && posi >= 0){
                                if (posi >=1){
                                        setColor(posi, "orange", "black");
                                        setColor(--posi, "blue", "white");
                                        textfield.value = outp.childNodes[posi].firstChild.nodeValue;
                                        llenar(outp.childNodes[posi].firstChild.nodeValue);
                                }
                                else{
                                        setColor(posi, "orange", "black");
                                        textfield.value = input;

                                        textfield.focus();
                                        posi--;

                                }

                        }

                }
                else if (key == 27){ // Esc
                        textfield.value = input;
                        setVisible("hidden");
                        posi = -1;
                        oldins = input;
                }
                else if (key == 8){ // Backspace
                        posi = -1;
                        oldins=-1;
                }
                else if (key == 13){ // Backspace
                        setVisible("hidden");
                        posi = -1;

                }

                }


        }


        function llenar(ss){
            var a = document.getElementsByName("a")[0];
            var b = document.getElementsByName("b")[0];
            var c = document.getElementsByName("c")[0];
            var arr;
            var dd;


                arr = ss.split(" | ");
                a.value = arr[0];
                b.value = arr[1];
                c.value = arr[2];

                if(c.value == 'undefined')
                   c.value = '';
        }


        var mouseHandler=function(){ 
                for (var i=0;i<words.length;++i)
                        setColor (i, "orange", "black");

                this.style.background = "blue";
                this.style.color= "white";
        }

        var mouseHandlerOut=function(){  
                this.style.background = "orange";
                this.style.color= "black";
        }

        var mouseClick=function(){
                document.getElementsByName("text")[0].value = this.firstChild.nodeValue;
                llenar(this.firstChild.nodeValue);
                setVisible("hidden");
                posi = -1;
                oldins = this.firstChild.nodeValue;

        }


</script>
<STYLE TYPE="text/css">

.output
{
        font-family:Arial;
        font-size: 10pt;
        color:black;
        padding-left: 3px;
        padding-top: 3px;
        border: 1px solid #000000;
        width: 100px;
        background: orange;
}
.shadow
{
        position:relative;
        top: 2px;
        left: 2px;
        background: #555;
}
.shadow div{
        position:relative;
        top: -2px;
        left: -2px;
        background: orange;
}

</STYLE>

<form name="test" id="test"><input type="hidden" name="PHPSESSID"  />
<input type="text" name="text" autocomplete="off">
                                                   
<input type="text" name="a" ><br>
<input type="text" name="b" ><br>
<input type="text" name="c" >
</form>
<div class="shadow" id="shadow">
<div class="output" id="output">
</div>
</div>
<script type="text/javascript">
init();
</script> 
__________________
"Vivir....solo cuesta Vida"
  #3 (permalink)  
Antiguo 11/04/2005, 14:55
Avatar de lalogrosz  
Fecha de Ingreso: mayo-2002
Ubicación: Capital Federal
Mensajes: 339
Antigüedad: 21 años, 11 meses
Puntos: 6
Proba esto: es un autocompletar, que funciona como un select, pero su ventaja es que se va reduciendo el listado.

en este array que tenes arriba de todo es donde se cargan los datos, que los podes llenar haciendo una consulta a la base y poniendolos de esta forma, separados por el caracter | . Debajo en la funcion llenar es donde los valores se copian al los tres textboxes. Si lo miras un poco lo vas a poder customizar para lo que necesitas. Suerte!!!
__________________
"Vivir....solo cuesta Vida"
  #4 (permalink)  
Antiguo 11/04/2005, 15:26
 
Fecha de Ingreso: agosto-2004
Ubicación: Stgo de Chile
Mensajes: 64
Antigüedad: 19 años, 8 meses
Puntos: 0
Ok, probaré, aunque pensé que el asunto sería más sencillo.
Gracias.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas




La zona horaria es GMT -6. Ahora son las 20:52.