<html>
<head>
<title>Selecciona elementos en lista</title>
<script LANGUAGE="JavaScript">
<!--
function moveVals(n, from, to) {
if (document.layers) {
fromObj = document.layers[from];
to = document.layers[to];
} else if (document.all) {
fromObj = document.all(from);
to = document.all(to);
}
if (n == 1 || n == 2) {
var indTo = to.length-1;
for (i=fromObj.length-1; i>=0; i--) {
if (n==1 || fromObj.options[i].selected) {
indTo++;
to.options[indTo] = new Option(fromObj.options[i].text, fromObj.options[i].value);
fromObj.options[i] = null;
}
}
} else if (n == 3 || n == 4) {
var indFrom = fromObj.length-1;
for (i=to.length-1; i>=0; i--) {
if (n==4 || to.options[i].selected) {
indFrom++;
fromObj.options[indFrom] = new Option(to.options[i].text, to.options[i].value);
to.options[i] = null;
}
}
}
}
function frmButtons() {
var select = "chosen";
var avail = "avail";
if (document.layers) {
var sel = document.layers[select];
var av = document.layers[avail];
} else if (document.all) {
var sel = document.all(select);
var av = document.all(avail);
}
if (sel.length <= 0) {
document.frmAddPro.btnR.disabled = true;
document.frmAddPro.btnRR.disabled = true;
} else {
document.frmAddPro.btnR.disabled = false;
document.frmAddPro.btnRR.disabled = false;
}
if (av.length <= 0) {
document.frmAddPro.btnL.disabled = true;
document.frmAddPro.btnLL.disabled = true;
} else {
document.frmAddPro.btnL.disabled = false;
document.frmAddPro.btnLL.disabled = false;
}
}
function deleteFrom() {
for (i=0; i<document.frmAddPro.elements.length-1; i++) {
if (document.frmAddPro.elements[i].tagName.indexOf("SELECT") && document.frmAddPro.elements[i].id.indexOf("av")) {
alert("Cislo: "+i+" Name: "+document.frmAddPro.elements[i].tagName);
}
}
}
-->
</script>
</head>
<body>
<center>
<form NAME="frmAddPro">
<table height="172">
<tr>
<td WIDTH="170" CLASS="selCell" style="background-color: #FFFFFF" height="14">
Ciudades disponibles:</td>
<td bgcolor="#FFFFFF" height="14"></td>
<td WIDTH="170" CLASS="selCell" style="background-color: #FFFFFF" height="14">
Tu favorita:</td>
</tr>
<tr>
<td height="150"><select MULTIPLE NAME="avail[]" ID="avail">
<option>Berlín</option>
<option>Londres</option>
<option>Luxemburgo</option>
<option>Nueva York</option>
<option>Paris</option>
<option>Praga</option>
<option>Tokyo</option>
</select> </td>
<td ALIGN="CENTER" VALIGN="CENTER" height="150">
<input TYPE="button" VALUE=">>" NAME="btnLL" onClick="moveVals(1, 'avail', 'chosen'); frmButtons(); return false;"><br>
<input TYPE="button" VALUE=">" NAME="btnL" onClick="moveVals(2, 'avail', 'chosen'); frmButtons(); return false;"><br>
<input TYPE="button" VALUE="<" NAME="btnR" onClick="moveVals(3, 'avail', 'chosen'); frmButtons(); return false;"><br>
<input TYPE="button" VALUE="<<" NAME="btnRR" onClick="moveVals(4, 'avail', 'chosen'); frmButtons(); return false;">
</td>
<td height="150"><select MULTIPLE NAME="chosen[]" id="chosen"></select>
</td>
</tr>
</table>
</form>
</center><br>
</body>
</html>