Foros del Web

Foros del Web (http://www.forosdelweb.com/)
-   Javascript (http://www.forosdelweb.com/f13/)
-   -   Error en codigo Javascript (http://www.forosdelweb.com/f13/error-codigo-javascript-568956/)

Silent88 25/03/2008 05:47

Error en codigo Javascript
 
Hola buenas a todos. Queria pedir ayuda por que no encuentro el error en un codigo y si no es asi no se como tendre que hacerlo, estoy estudiando un modulo medio de informatica y me mandaron una practica y la verdad que llevo bastante tiempo buscando el error o otra manera de hacerla pero no se me ocurre nada y tengo un libro el cual no me resuelve nada.
La foto de la practica la he colgado en la siguiente pagina
http://www.fotazas.com/v2/photo_lzzy2tqqtygkvftmzna5.jpg.htm
no la he subido aqui porque no se veia bien.

Y este es el codigo que yo he puesto:

<HTML>
<HEAD>
<TITLE>Modificacion de formato de texto</TITLE>
</HEAD>
<BODY>
<DIV id="textop" ; font-family: Arial;>
<p id="desc">&nbsp</p>
</DIV>
<br>
<td colspan="2" align="center"> <input name="Alinear" type="button" value="Alinear" onclick="alineartexto();"></td>
<br>
<br>
<td colspan="2" align="center"> <input name="Tamaño" type="button" value="Tamaño" onclick="tamañotexto();"></td>
<br>
<br>
<td colspan="2" align="center"> <input name="Color fondo" type="button" value="Color fondo" onclick="colorfondo();"></td>
<br>
<br>
<td colspan="2" align="center"> <input name="Color texto" type="button" value="Color texto" onclick="colortexto();"></td>
<br>
<br>
<td colspan="2" align="center"> <input name="Letra texto" type="button" value="Letra texto" onclick="letratexto();"></td>
<br>
<br>
<td colspan="2" align="center"> <input name="Estilo" type="button" value="Estilo" onclick="estilotexto();"></td>

<SCRIPT LANGUSGE= "JavaScript">
<!--
var texto = prompt("Introduce un texto","")
document.getElementById("desc").firstChild.nodeVal ue= texto;
var num_colores=0;
{
num_colores++
}
if(num_colores > 5);
{
switch (num_colores)
{
case 1:
function colortexto() {
textop.style.color= "Red";
}
break;
case 2:
function colortexto() {
textop.style.color= "Green";
}
break;
case 3:
function colortexto() {
textop.style.color= "Blue";
}
break;
case 4:
function colortexto() {
textop.style.color= "Orange";
}
break;
case 5:
function colortexto() {
textop.style.color= "Black";
}
break;
}

{
num_colores++
}
if(num_colores > 5);
{
switch (num_colores)
{
case 1:
function colorfondo() {
textop.style.backgroundColor= "Red";
}
break;
case 2:
function colorfondo() {
textop.style.backgroundColor= "Green";
}
break;
case 3:
function colorfondo() {
textop.style.backgroundColor= "Nlue";
}
break;
case 4:
function colorfondo() {
textop.style.backgroundColor= "Orange";
}
break;
case 5:
function colorfondo() {
textop.style.backgroundColor= "Black";
}
break;
}

{
num_colores++
}
if(num_colores > 5);
{
switch (num_colores)
{
case 1:
function letratexto() {
textop.style.fontFamily= "Comic Sans Ms";
}
break;
case 2:
function letratexto() {
textop.style.fontFamily= "Verdana";
}
break;
case 3:
function letratexto() {
textop.style.fontFamily= "Times New Roman";
}
break;
case 4:
function letratexto() {
textop.style.fontFamily= "Vrinda";
}
break;
case 5:
function letratexto() {
textop.style.fontFamily= "SimSun";
}
break;
}

{
num_colores++
}
if(num_colores > 7);
{
switch (num_colores)
{
case 1:
function estilotexto() {
textop.style.fontFamily= "Cursive","Underline";
}
break;
case 2:
function estilotexto() {
textop.style.fontFamily= "Black";
}
break;
case 3:
function estilotexto() {
textop.style.fontFamily= "Cursive";
}
break;
case 4:
function estilotexto() {
textop.style.fontFamily= "Underline";
}
break;
case 5:
function estilotexto() {
textop.style.fontFamily= "Black","Cursive";
}
break;
case 6:
function estilotexto() {
textop.style.fontFamily= "Black","Underline";
}
break;
case 7:
function estilotexto() {
textop.style.fontFamily= "Black","Cursive","Underline";
}
break;
}

{
num_colores++
}
if(num_colores > 5);
{
case 1:
function tamañotexto() {
textop.style.fontSize= "18pt";
}
break;
case 2:
function tamañotexto() {
textop.style.fontSize= "12pt";
}
break;
case 3:
function tamañotexto() {
textop.style.fontSize= "25pt";
}
break;
case 4:
function tamañotexto() {
textop.style.fontSize= "30pt";
}
break;
case 5:
function tamañotexto() {
textop.style.fontSize= "8pt";
}
break;
}

{
num_colores++
}
if(num_colores > 3);
{
case 1:
function alineartexto() {
textop.style.textTransform= "uppercase";
textop.style.textIndent= "3cm";
}
break;
case 2:
function alineartexto() {
textop.style.textTransform= "uppercase";
textop.style.textIndent= "8cm";
}
break;
case 3:
function alineartexto() {
textop.style.textTransform= "uppercase";
textop.style.textIndent= "12cm";
}
break;
}
// -->
</SCRIPT>
</BODY>
</HTML>
Espero vuestros comentarios, gracias ;)
Saludos a todos.

marcopoloaz06 25/03/2008 13:07

Re: Error en codigo Javascript
 
Hola, deberias de leer un manual de javascript
librosweb.es/javascript/

Ahi esta sin error
Código HTML:

<HTML>
<HEAD>
<TITLE>Modificacion de formato de texto</TITLE>
</HEAD>
<BODY>
<DIV id="textop" style=" font-family: Arial;">
<p id="desc"></p>
</DIV>
<br>
<td colspan="2" align="center"> <input name="Alinear" type="button" value="Alinear" onclick="alineartexto();"></td>
<br>
<br>
<td colspan="2" align="center"> <input name="Tamaño" type="button" value="Tamaño" onclick="tamañotexto();"></td>
<br>
<br>
<td colspan="2" align="center"> <input name="Color fondo" type="button" value="Color fondo" onclick="colorfondo();"></td>
<br>
<br>
<td colspan="2" align="center"> <input name="Color texto" type="button" value="Color texto" onclick="colortexto();"></td>
<br>
<br>
<td colspan="2" align="center"> <input name="Letra texto" type="button" value="Letra texto" onclick="letratexto();"></td>
<br>
<br>
<td colspan="2" align="center"> <input name="Estilo" type="button" value="Estilo" onclick="estilotexto();"></td>

<SCRIPT LANGUAGE= "JavaScript">
<!--
var texto = prompt("Introduce un texto","")
document.getElementById("desc").innerHTML= texto;
var num_colores=0;
textop=document.getElementById("desc");

num_colores++


if(num_colores >
3);
{
switch(num_colores){
case 1:
function alineartexto() {
textop.style.textTransform= "uppercase";
textop.style.textIndent= "3cm";
}
break;
case 2:
function alineartexto() {
textop.style.textTransform= "uppercase";
textop.style.textIndent= "8cm";
}
break;
case 3:
function alineartexto() {
textop.style.textTransform= "uppercase";
textop.style.textIndent= "12cm";
}
break;
}
}

if(num_colores > 5);
{
switch (num_colores)
{
case 1:
function colortexto() {
textop.style.color= "Red";
}
break;
case 2:
function colortexto() {
textop.style.color= "Green";
}
break;
case 3:
function colortexto() {
textop.style.color= "Blue";
}
break;
case 4:
function colortexto() {
textop.style.color= "Orange";
}
break;
case 5:
function colortexto() {
textop.style.color= "Black";
}
break;
}
}

num_colores++

if(num_colores > 5);
{
switch (num_colores)
{
case 1:
function colorfondo() {
textop.style.backgroundColor= "Red";
}
break;
case 2:
function colorfondo() {
textop.style.backgroundColor= "Green";
}
break;
case 3:
function colorfondo() {
textop.style.backgroundColor= "Nlue";
}
break;
case 4:
function colorfondo() {
textop.style.backgroundColor= "Orange";
}
break;
case 5:
function colorfondo() {
textop.style.backgroundColor= "Black";
}
break;
}
}


num_colores++

if(num_colores > 5);
{
switch (num_colores)
{
case 1:
function letratexto() {
textop.style.fontFamily= "Comic Sans Ms";
}
break;
case 2:
function letratexto() {
textop.style.fontFamily= "Verdana";
}
break;
case 3:
function letratexto() {
textop.style.fontFamily= "Times New Roman";
}
break;
case 4:
function letratexto() {
textop.style.fontFamily= "Vrinda";
}
break;
case 5:
function letratexto() {
textop.style.fontFamily= "SimSun";
}
break;
}
}


num_colores++

if(num_colores > 7);
{
switch (num_colores)
{
case 1:
function estilotexto() {
textop.style.fontFamily= "Cursive","Underline";
}
break;
case 2:
function estilotexto() {
textop.style.fontFamily= "Black";
}
break;
case 3:
function estilotexto() {
textop.style.fontFamily= "Cursive";
}
break;
case 4:
function estilotexto() {
textop.style.fontFamily= "Underline";
}
break;
case 5:
function estilotexto() {
textop.style.fontFamily= "Black","Cursive";
}
break;
case 6:
function estilotexto() {
textop.style.fontFamily= "Black","Underline";
}
break;
case 7:
function estilotexto() {
textop.style.fontFamily= "Black","Cursive","Underline";
}
break;
}
}


num_colores++

if(num_colores > 5);
{
switch(num_colores){
case 1:
function tamañotexto() {
textop.style.fontSize= "18pt";
}
break;
case 2:
function tamañotexto() {
textop.style.fontSize= "12pt";
}
break;
case 3:
function tamañotexto() {
textop.style.fontSize= "25pt";
}
break;
case 4:
function tamañotexto() {
textop.style.fontSize= "30pt";
}
break;
case 5:
function tamañotexto() {
textop.style.fontSize= "8pt";
}
break;
}
}


// -->

</SCRIPT>
</BODY>
</HTML>

adios

Silent88 25/03/2008 15:22

Re: Error en codigo Javascript
 
Muchisims gracias Marcopoloaz06 ya se me ve y sale todo, el unico poblem que engo ahora eske se ve todo pero cuando pulsas mas de un vez no rota se queda en el prmero, por ejmplo no cambia la letra lo diferentes estilos.
Saludos y gracias de nuevo.


La zona horaria es GMT -6. Ahora son las 15:38.

Desarrollado por vBulletin® Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.