necesito de su voluntad para resolver mi problema, tengo que llenar un Select multiple llamado (EquipDesp) con los valores de 4 select, ( Mandante, Obras, Areas, Equipos) el problema no radica ahí sino en verificar que se selecciones los 4 select para agregar un nuevo valor a la lista y validar que no se ingresen duplicados en la misma.
ahora un poco de codigo
El Formulario
Código PHP:
<table border="1">
<tbody>
<tr>
<td>Mandantes</td>
<td>
<SELECT name="Mandantes">
<OPTION selected="0">seleccione</OPTION>
<OPTION value="ryv">ryv</OPTION>
</SELECT>
</td>
<td rowspan="2">
<INPUT type="button" name=">>" value=">>" class="button" onclick="verificaIns(this.form)">
</td>
<td rowspan="4">
<SELECT id="EquipDesp" name="EquipDesp[]" multiple size="22" class="textbox" style="width:400px">
</SELECT>
</td>
</tr>
<tr>
<td>Obras</td>
<td>
<SELECT name="Obras" multiple="true">
<OPTION selected="0">seleccione</OPTION>
<OPTION value="cerro">cerro</OPTION>
</SELECT>
</td>
</tr>
<tr>
<td>Areas</td>
<td>
<SELECT name="Areas">
<OPTION selected="0">seleccione</OPTION>
<OPTION value="Suelos">Suelos</OPTION>
<OPTION value="Hormigon">Hormigon</OPTION>
</SELECT>
</td>
<td rowspan="2">
<INPUT type="button" name="<<" value="<<" class="button">
</td>
</tr>
<tr>
<td>Equipos</td>
<td>
<SELECT name="Equipos" multiple="true">
<OPTION selected="0">seleccione</OPTION>
<OPTION value="S01">Balanza</OPTION>
<OPTION value="S02">Varilla</OPTION>
<OPTION value="S03">Prensa</OPTION>
<OPTION value="S04">Molde</OPTION>
</SELECT>
</td>
</tr>
</tbody>
</table>
Código PHP:
<script>
Function verificaIns(this.form){
// Obtengo las variables
Mandantes= document.getElementById("Mandantes");
Areas= document.getElementById("Areas");
Obras= document.getElementById("Obras");
Equipos= document.getElementById("Equipos");
EquipDesp = document.getElementById("EquipDesp");
// Hago las validaciones
if ((Mandantes.value == "0") || (Mandantes.value == null)) {
alert("Por favor selecciona un Mandante");
Mandantes.focus();
return false;
}
else
if ((Obras.value == "0") || (Obras.value== null)) {
alert("Por favor selecciona una Obra");
Obras.focus();
return false;
}
else
if ((Areas.value == "0") || (Areas.value== null)) {
alert("Por favor selecciona una Area");
Areas.focus();
return false;
}
else
if ((Equipos.value == "0") || (Equipos.value== null)) {
alert("Por favor selecciona un Equipo");
Equipos.focus();
return false;
}
// busco en la lista si existe un valor igual
for (i=0; opti = EquipDesp.options[i]; i++){
if (opti.value == Mandantes.value+"|"+Obras.value+"|".Equipos.value)
{
alert('Ya existe en lista');
}
}
//esta es la parte que ingresa la nueva opcion
opt = new Option(Mandantes.value+"|"+Obras.value+"|"+Equipos.value,Mandantes.value+"|"+Obras.value+"|"+Equipos.value);
EquipDesp.options[EquipDesp.options.length] = opt;
}
</script>
ayuda Pleace