Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/04/2011, 09:05
alfa18
 
Fecha de Ingreso: diciembre-2007
Mensajes: 299
Antigüedad: 16 años, 4 meses
Puntos: 2
Pregunta Respuesta: problemas con metodos select

Gracias JavierB, lo probe y funciona perfectamente......muchas gracias me tenia loco este eror

Veras, ahora me surgio un problema similar al anterior pero a la hora de añadir un OPTION al SELECT(metodo add())). Te envio el codigo JS:

<HTML>
<HEAD><TITLE>Caso practico JavaScript</TITLE>
<script type="text/javascript">
function AddElementoSelect(x,txt,val){
//fn que recibe el SELECT y le añade la OPTION txt(val)
if(txt.value=="") {
alert("Introduzca elemento de texto a añadir");
txt.focus();
exit; //sale de la fn en espera de mas datos
}

if(val.value=="") {
alert("Introduzca valor asociado al elemento a añadir");
val.focus();
exit;
}
x.add(txt.value,x.options[null]);
txt.value="";val.value="";
}

</script></HEAD>

<BODY bgcolor="orange">
<FORM name="form">
SELECT<select id="continente" size="7" multiple>
<option value="America">América</option>
<option value="Africa">África</option>
<option value="Asia">Asia</option>
<option value="Europa">Europa</option>
<option value="Oceania">Oceanía</option>
</select>
<BR>
Nuevo elemento:<BR>Texto<INPUT type="text" name="txt1"><BR>Valor<INPUT type="text" name="txt2"><BR>
<INPUT type="button" value="Añadir al select" onclick="AddElementoSelect(form.continente,form.tx t1,form.txt2)"><BR>
<INPUT type="button" value="Quitar del select" onclick="QuitarElementoSelect(form.continente,form .txt2)"><BR>
<INPUT type="button" value="Vaciar select" onclick="LimpiarSelect(form.continente)">
<P>RADIO<BR>
Primera <INPUT type="radio" name="ord" value="Primera" checked onclick="activar()"><BR>
Segunda <INPUT type="radio" name="ord" value="Segunda" onclick="activar()"><BR>
Tercera <INPUT type="radio" name="ord" value="Tercera" onclick="activar()"><BR>
<INPUT type="button" name="B1" value="Desmarcar todo" onclick="limpiaRB(form)">
<INPUT type="button" name="B2" value="Valor actual" onclick="valorRB(form)"> <INPUT type="button" value="Marca el segundo" onclick="ponvalorRB(form,'Segunda')">
</FORM>
</BODY>
</HTML>

Lo del "x.options[null]" lo saque de esta web: http://www.w3schools.com/jsref/met_select_add.asp, pero no se por que me da error en esa linea ¿alguna sugerencia?

Gracias de nuevo JavierB, saludos:D