David Golightly escribió:
Winston wrote:
>I want to changue the stylesheet for this page.
Why the form select doesn't work?
link id="est" rel="stylesheet " type="text/css" href="est.css">
function Changue() {
var posibles = document.forms[0].XXX;
document.getEl ementById("est" ).href=posibles .options[posibles.select edIndex].value;
}
<form>
¿Changue to <select name="XXX" onChangue="Chan gue()">
<option selected value"estilo1.c ss"Estilo 1? </option>
<option value"estilo2.c ss"Estilo 2? </option>
<option value"estilo3.c ss"Estilo 3? </option>
</select>
</form>
First off, It's "onchange" not "onChangue" . The word does not have a
"u" in it.
Also, what's going on with your HTML? Where's your "body" tag?
Where's your "html" tag? Why do you have script just there, not in a
"script" tag? Why do you have value"estilo1.c ss" - you need to have
value="estilo1. css" with an "=" between the attribute and the value.
Fix these things and this will work for you. But more troubling is
that these are all very basic things - go get a book on HTML and learn
HTML before starting to learn JavaScript. You really need to have a
solid HTML foundation before starting JavaScript.
Good luck,
David
Sorry, I didn't want to paste spanish code.
But you help me a lot with the onchange!
Thanks!
<html>
<head>
<title>Javascri pt 1 - document.write. ..</title>
</head>
<link id="estilos" rel="stylesheet " type="text/css" href="estilo2.c ss">
<script languaje="JavaS cript">
function verifica(numero , cantidad) {
var sms = "Debe Ingresar un entero";
if (isNaN(numero)) {
document.getEle mentById("error 1").innerHTM L = "Debe Ingresar
un entero";
return false;
}
if (isNaN(cantidad )) {
document.getEle mentById("error 2").innerHTM L = "Debe Ingresar
un entero";
return false;
}
else
return true;
}
/* Genera las tablas de multiplicar y agrego otras operaciones, una fila
por cada ejecucion del for */
function generar_tabla(d el_form) {
var salida = "";
var m = del_form.multip licador.value;
var cantidad = del_form.cantid ad.value;
m = parseInt(m)
cantidad = parseInt(cantid ad)
if (verifica(m, cantidad)) {
salida ="<html><head>< title>Codigo generado por una linea
for!</title></head><link rel='stylesheet ' type='text/css'
href='estilo2.c ss'>"
salida +="<table border='5' width='95%' align='center'
cellspacing='8' cellpadding='10 '>"
salida
+="<tr><th>Mult iplica</th><th>Suma</th><th>Resta</th><th>Divide</th></tr>"
salida +="<tr align='center'> <td</td<td</td> <td></td>
<td></td</tr>"
for (var i=1; i<=cantidad; i++)
salida
+="<tr><td>"+i+ "*"+m+"="+(i*m) +"</td><td>"+i+"+"+ m+"="+(i+m)+" </td><td>"+i+"-"+m+"="+(i-m)+"</td><td>"+i+"/"+m+"="+(i/m)+"</td></tr>"
salida += "</table></body</html>"
document.write( salida);
return true;
}
else {
return false;
}
}
function Cambiar() {
/* Es el primer Formulario de la pagina */
var posibles = document.forms[0].Seleccionar;
document.getEle mentById("estil os").href=posib les.options[posibles.select edIndex].value;
}
</script>
<body>
<div id="Menu">
<hr/>
<ul>
<li><a href="objetivo. html" title="Objetivo ">Introducc ion</a>
<li><a href="cv.html" title="Texto + Listas -
(C.V.)">C.V</a></li>
<li><a href="multimedi a.html" title="Multimed ia">Multimedi a</a></li>
<li><a href="dondeestu ve.html" title="Enlaces" >Enlaces</a>
<li><a href="preguntas .html" title="Pregunta s">Preguntas </a><ul>
<li><a href="preg_html .html" title="Pregunta s sobre
HTML">HTML</a></li>
<li><a href="preg_css. html" title="Pregunta s sobre
CSS">CSS</a></li>
<li><a href="preg_java script.html" title="Pregunta s sobre
JavaScript">Jav aScript</a></li>
<li><a href="preg_php. html" title="Pregunta s sobre
PHP">PHP</a></li></ul>
<li><a href="horarios. html" title="Horario de clase">Horario</a><ul>
<li><a href="horario1. html" title="Horario
(Tablas)">Horar io (Tablas)</a></li>
<li><a href="horario2. html" title="Horario
(Capas)">Horari o (Capas)</a></li </ul>
<li><a href="formulari os.html" title="Formular io">Formularios </a>
<ul>
<li><a href="salida.ht ml" title="Formular io -
Submit">Formula rios (Haciendo el Submit)</a></li></ul>
<li><a href="imagen_0. html" title="Imagenes Inmenzas">Image nes
Inmenzas</a <ul>
<li><a href="imagen_1. html" title="Imagenes
Inmenzas">Parti endo en una tabla</a></li>
<li><a href="imagen_2. html" title="Imagenes Inmenzas">Con
Celsspading=0</a></li>
<li><a href="imagen_3. html" title="Imagenes Inmenzas">Con
Border=0</a></li </ul>
<li><a href="javascrip t.html" title="JavaScri pt">Javascrip t</a>
<ul>
<li><a href="j_tabla.h tml" title="Tabla de Multiplicar y
mas...">Tabla de Multiplicar</a></li>
<li><a href="j.html" title="Mas cosas de
JavaScript">??</a></li>
<li><a href="imagen_3. html" title="Mas">??</a></li </ul>
</ul>
<hr/>
<center<a
href="mailto:ol ************@ya hoo.es">ol***** *******@yahoo.e s</a</center>
<hr/>
<form>
¿Cambiar a <select name="Seleccion ar" onChange="Cambi ar()">
<option selected value="estilo1. css"Estilo 1?
</option>
<option value="estilo2. css"Estilo 2? </option>
<option value="estilo3. css"Estilo 3? </option>
</select>
</form>
<hr/>
</div>
<div id="Contenido" >
<form onSubmit = "return generar_tabla(t his)">
<table>
<tr>
<td style="width: 10em">Su Nombre:</td>
<td><input type=text name="nombre" size="35" maxlength="50"> </td>
</tr>
<tr>
<td>Generar tabla del numero:</td>
<td><input type=text name="multiplic ador" size="35" maxlength="5"></td>
<!-- Aqui pondre el mensaje que yo quiera para avisar del error,
recomiendan que ese campo tenga "algo" -->
<td id="error1">&nb sp;</td>
</tr>
<tr>
<td>Cantidad de filas de la tabla</td>
<td><input type=text name="cantidad" size="35" maxlength="5"></td>
<td id="error2">&nb sp;</td>
</tr>
<tr>
<td><input type="submit" value="Generar Tabla"</td>
</tr>
</table>
</form>
</div>
</body>
</html>