Aqui está el código:
en consola javascript me da los siguientes errores:
"Error: missing variable name
Código fuente:
var long = document.form1.autores.length;"
"Error: Mifuncion is not defined"
Les pido que me ayuden
Código HTML:
<script>
function Mifuncion(){
alert("Prueba"); }
function prueba1(){
var index = document.form1.id_autor.selectedIndex;
var long = document.form1.autores.length;
var text = document.form1.id_autor.options[index].text;
var value = document.form1.id_autor.options[index].value;
var option1 = new Option(text,value);
array.push(value);
document.form1.autores.options[long]= option1 ;
document.form1.autores.options[long].selected= true;
document.form1.autores1.value = array;
}
</script>
<HTML>
<HEAD>
<TITLE>Select object example</TITLE>
</HEAD>
<BODY>
<FORM NAME="form">
<table width="473" height="276" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="19" colspan="3" align="right" valign="top"> </td>
</tr>
<tr>
<td width="109" height="28" align="right" valign="top"> Autores
</td>
<td width="302" height="28" align="left" valign="top"><p>
<select name="id_autor" id="id_autor">
<option value="">Seleccione</option>
</select>
<input name="Agregar" type="button" id="Agregar" value="Agregar" onClick="Mifuncion()">
</p> </td>
<td width="62" rowspan="3"> </td>
</tr>
<tr>
<td height="91" align="right" valign="top"> </td>
<td align="left" valign="top">
<select name="autores" size="5" multiple id="autores" >
</select>
</td>
</tr>
<tr>
<td height="54" align="right" valign="top">Resumen: </td>
<td align="left" valign="top"><table width="204" height="32" border="0" cellpadding="0" cellspacing="0">
<tr>
<td><input type="submit" name="Submit" value="Insertar" ></td>
<td><input type="reset" name="Submit2" value="Cancelar"></td>
</tr>
</table></td>
</tr>
<tr align="center" valign="middle">
<td colspan="3">
</td>
</tr>
</table>
</form>
</BODY>
</HTML>