Ver Mensaje Individual
  #1 (permalink)  
Antiguo 02/01/2014, 07:57
Avatar de tekilalemon
tekilalemon
 
Fecha de Ingreso: enero-2014
Mensajes: 4
Antigüedad: 10 años, 4 meses
Puntos: 0
Cambiar value de un input text

Hola, estoy intentando cambiar el value de unos input text segun el idioma que obtenga del lang de la etiqueta html.

Este es mi archivo js:

Código:
idioma = document.getElementsByTagName("html")[0].getAttribute("lang");

descripcion = document.getElementById('edit-field-pdf-informacion-obra-und-0-description');
cartel = document.getElementById('edit-field-pdf-cartel-obra-und-0-description');

if(idioma=="es"){
	descripcion.value="Description";
	cartel.value="Cartel";
}
else if(idioma=="en"){
	descripcion.value="Description";
	cartel.value="Cartel";
}
else{
	descripcion.value="Informations";
	cartel.value="Affiche";
}
Y este es mi archivo html donde están los inputs:

Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="es" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>

<script src="descripcion-cartel.js" type="text/javascript"></script>

</head>

<input type="text" id="edit-field-pdf-informacion-obra-und-0-description" name="field_pdf_informacion_obra[und][0][description]" value="Des1" size="60" maxlength="128" class="form-text">

<input type="text" id="edit-field-pdf-cartel-obra-und-0-description" name="field_pdf_cartel_obra[und][0][description]" value="Car1" size="60" maxlength="128" class="form-text">

<body>
</body>
</html>
Aparentemente debería cambiar los valores pero no lo hace.
También he probado con setAttribute("value","valor");
Pero nada. En el firebug del firefox siempre me dice que estan null.

Alguen me ayuda?
Gracias de antemano!!