
07/05/2007, 13:27
|
 | | | Fecha de Ingreso: julio-2003
Mensajes: 1.773
Antigüedad: 21 años, 7 meses Puntos: 21 | |
Re: problemas con mi funcion javascript prueba asi
<select size="4" name="dirigido[]" id="dirigido" multiple onMouseDown="GetCurrentListValues(this);" onchange="FillListValues(this);" class="selectx">
<option value="2" selected>Alumno</option>
<option value="4">Catedratico</option>
<option value="8">Administrativo</option>
<option value="16">Directivo</option>
<option value="1">Invitado</option>
<option value="v">Visitante</option>
</select>
<script>
var arrOldValues;
function SelectAllList(CONTROL){
for(var i = 0;i < CONTROL.length;i++){
CONTROL.options[i].selected = true;
}
}
function DeselectAllList(CONTROL){
for(var i = 0;i < CONTROL.length;i++){
CONTROL.options[i].selected = false;
}
}
function FillListValues(CONTROL){
var arrNewValues;
var intNewPos;
var strTemp = GetSelectValues(CONTROL);
arrNewValues = strTemp.split(",");
for(var i=0;i<arrNewValues.length-1;i++){
if(arrNewValues[i]==1){
intNewPos = i;
}
}
for(var i=0;i<arrOldValues.length-1;i++){
if(arrOldValues[i]==1 && i != intNewPos){
CONTROL.options[i].selected= true;
}
else if(arrOldValues[i]==0 && i != intNewPos){
CONTROL.options[i].selected = false;
}
if(arrOldValues[intNewPos]== 1){
CONTROL.options[intNewPos].selected = false;
}
else{
CONTROL.options[intNewPos].selected = true;
}
}
}
function GetSelectValues(CONTROL){
var strTemp = "";
for(var i = 0;i < CONTROL.length;i++){
if(CONTROL.options[i].selected == true){
strTemp += "1,";
}
else{
strTemp += "0,";
}
}
return strTemp;
}
function GetCurrentListValues(CONTROL){
var strValues = "";
strValues = GetSelectValues(CONTROL);
arrOldValues = strValues.split(",")
}
</script>
__________________ gerardo |