Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/03/2010, 11:45
Avatar de fenix4
fenix4
 
Fecha de Ingreso: noviembre-2001
Ubicación: Caracas
Mensajes: 226
Antigüedad: 22 años, 5 meses
Puntos: 1
error con DOCTYPE

Amigos estoy tratando de agregar unos elementos a un select(bombobox), practique con unos ejemplo y todo normal, luego lo lleve a mi código y no me funciono, luego de varias horas me di cuenta por que no me funcionaba. Es un problema con el DOCTYPE, les dejo el ejemplo que no funciona con la declaración correcta.

Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es">

<head>

	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

	<title>CCNPG - Sistema de Registro de Programas de Doctorados</title>

	<link href="css/estilos.css" rel="stylesheet" type="text/css">

	<script language="JavaScript" type="text/javascript" src="ajax/funciones4.js">
	</script>
<script>
function add()
{    
   op = document.createElement('OPTION');
   var newOpt = mySel.appendChild(op);
	total=mySel.options.length;
	newOpt.value = total;    
   newOpt.text = 'Item '+total;
   
}
</script>
</head>

<body>.<br>
	<form name="formulario" >
		<select id="mySel" multiple>
			<option>Item 1
		</select><br>		
		<a href="javascript:add();">Add</a>
	</form>
</body>
</html> 
Luego tenemos el DOCTYPE que si funciona, lo que hice fue quitarle un uno

Código HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="es" xml:lang="es">

<head>

	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

	<title>CCNPG - Sistema de Registro de Programas de Doctorados</title>

	<link href="css/estilos.css" rel="stylesheet" type="text/css">

	<script language="JavaScript" type="text/javascript" src="ajax/funciones4.js">
	</script>
<script>
function add()
{    
   op = document.createElement('OPTION');
   var newOpt = mySel.appendChild(op);
	total=mySel.options.length;
	newOpt.value = total;    
   newOpt.text = 'Item '+total;
   
}
</script>
</head>

<body>.<br>
	<form name="formulario" >
		<select id="mySel" multiple>
			<option>Item 1
		</select><br>		
		<a href="javascript:add();">Add</a>
	</form>
</body>
</html> 
osea con el doctype correcto no me funciona:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

pero si le quito el 1, funciona excelente
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

Por que ocurre esto?? estoy novato con el JS, me documente pero dice que la primera version es la forma correcta de usar el doctype.. entonces????
__________________
S.L.P.S.