Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/06/2010, 13:26
Esther16
 
Fecha de Ingreso: febrero-2010
Mensajes: 6
Antigüedad: 14 años, 2 meses
Puntos: 0
Llenar un select desde BD y a su vez ingresar o eliminar Selects

Buenos Dias

Mi problema es el siguiente tengo un formulario que presentar tipos de ayudas en 3 select ahora me solicitaron que el usuario ingrese o elimine el numero de selects , este select se llena desde la Base de Datos , tengo un codigo que crea y elimina los select en Java Script el problema es el enlace a la BD que debe tener select , se que Js trabaja del lado del usuario por eso a colocar <?php ?> no los procesa , me puede aconsejar de que otra manera pueda hacer esto , o que cambios debo hacerle al codigo.

De antemano Gracias por Responder.

Anexo el Codigo :

registro_atendido.js

var arrInput = new Array(0);
var arrInputValue = new Array(0);


function addInput()
{
arrInput.push(arrInput.length);
arrInputValue.push("");
display();
}

function display()
{
document.getElementById('nuevoInput').innerHTML="" ;
for (intI=0;intI<arrInput.length;intI++)
{
document.getElementById('nuevoInput').innerHTML+=c reateInput(arrInput[intI], arrInputValue[intI]);
}
}

function saveValue(intId,strValue)
{
arrInputValue[intId]=strValue;
}



function createInput(id,value)
{



//"<input type='text' id='test "+ id +"' onChange='javascript:saveValue("+ id +",this.value)' value='"+ value +"'><br>";



return " <?php $ayudas."+ id +" = $obj_principal->consulta_ayuda(); ?>
<select name="ayudas"+ id +"" id="ayudas"+ id +"" <?php echo $ayudas"+ id +" ?>>

<?php
do{
?>
<option value="<?php echo $ayudas"+ id +"['fila']['codigo_ayuda']; ?>"> <?php echo $ayudas"+ id +"['fila']['nombre_ayu']; ?></option>
<?php
} while ($ayudas"+ id +"['fila'] = $obj_principal->io_conexiones->fetch_row($ayudas"+ id +"['rs']));
?>
<option value="0"> </option>
</select>
</select>";



}


function deleteInput()
{
if (arrInput.length > 0)
{
arrInput.pop();
arrInputValue.pop();
}
display();
}


registro_atendido.php

<table width="328">
<tr>
<td width="124">
<label class="desc">Tipo de Ayuda</label></td>
<td width="102" align="center"><a href="javascript:addInput();"><img src="http://www.forosdelweb.com/f18/images/Plus__Orange.png" align="center" alt="Buscar" width="25" height="25" border="0" title="Agregar Ayuda" /></a></td>
<td width="102" align="center">
<a href="javascript:deleteInput();"><img src="http://www.forosdelweb.com/f18/images/1275062198_button_cancel.png" align="center" alt="Buscar" width="25" height="25" border="0" title="Eliminar Ayuda" /></a> </td>
</tr>
<tr>
<td> </td>
<td align="center">
<label>Agregar Ayuda</label> </td>
<td align="center">
<label>Eliminar Ayuda</label> </td>
</tr>
<tr>
<td id="nuevoInput" colspan="5">&nbsp;</td>
</tr>
</table>

Última edición por Esther16; 02/06/2010 a las 13:32