JavaScript - Ayuda Error en Javascript

 
Vista:

Ayuda Error en Javascript

Publicado por Silent88 (1 intervención) el 25/03/2008 17:17:07
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

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"> </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.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ayuda Error en Javascript

Publicado por pepe lui (1 intervención) el 26/03/2008 16:50:20
<html>

<head>

<title>Cosas</title>

<style type="text/css">
#contenedor{
margin: 0;
padding: 0;
border: 1px solid #000;
width: 400;
height: 100;
}

input{
width: 150px;
}
</style>

<script type="text/javascript">
var texto = prompt ("Escribe algo:", "algo");

var contenedor;

var alineamientos = Array ("left", "right", "center");
var alineamientos_textos = Array ("izquierda", "derecha", "centro");
var alineamientos_indice = -1;

var tamanos = Array ("8px", "16px", "24px", "32px", "40px");
var tamanos_textos = Array ("8", "16", "24", "32", "40");
var tamanos_indice = -1;

var colores_fondo = Array ("FFFFFF", "FF0000", "00FF00", "0000FF", "000000");
var colores_fondo_textos = Array ("blanco", "rojo", "verde", "azul", "negro");
var colores_fondo_indice = -1;

var colores_texto = Array ("000000", "FF0000", "00FF00", "0000FF", "FFFFFF");
var colores_texto_textos = Array ("negro", "rojo", "verde", "azul", "blanco");
var colores_texto_indice = -1;

var fuentes = Array ("Courier", "Verdana", "Helvetica", "Georgia", "Arial");
var fuentes_indice = -1;

var estilos_textos = Array ("negrita", "cursiva", "subrayado", "negrita-cursiva", "negrita-subrayado", "cursiva-subrayado", "negrita-cursiva-subrayado");
var estilos_indice = -1;

window.onload = inicio;

function inicio (){
contenedor = document.getElementById ("contenedor");

contenedor.innerHTML = texto;

alineamiento ();
tamano ();
color_fondo ();
color_texto ();
fuente ();
estilo ();
}

function alineamiento (){
alineamientos_indice = (alineamientos_indice + 1) % alineamientos.length;
contenedor.style.textAlign = alineamientos[alineamientos_indice];

document.getElementById ("texto_alineamiento").innerHTML = alineamientos_textos[alineamientos_indice];
}

function tamano (){
tamanos_indice = (tamanos_indice + 1) % tamanos.length;
contenedor.style.fontSize = tamanos[tamanos_indice];

document.getElementById ("texto_tamano").innerHTML = tamanos_textos[tamanos_indice];
}

function color_fondo (){
colores_fondo_indice = (colores_fondo_indice + 1) % colores_fondo.length;
contenedor.style.backgroundColor = colores_fondo[colores_fondo_indice];

document.getElementById ("texto_color_fondo").innerHTML = colores_fondo_textos[colores_fondo_indice];
}

function color_texto (){
colores_texto_indice = (colores_texto_indice + 1) % colores_texto.length;
contenedor.style.color = colores_texto[colores_texto_indice];

document.getElementById ("texto_color_texto").innerHTML = colores_texto_textos[colores_texto_indice];
}

function fuente (){
fuentes_indice = (fuentes_indice + 1) % fuentes.length;
contenedor.style.fontFamily = fuentes[fuentes_indice];

document.getElementById ("texto_fuente").innerHTML = fuentes[fuentes_indice];
}

function estilo (){
estilos_indice = (estilos_indice + 1) % estilos_textos.length;

switch (estilos_indice){
case 0: // negrita
contenedor.style.fontWeight = "bold";
contenedor.style.fontStyle = "normal";
contenedor.style.textDecoration = "none";
break;
case 1: // cursiva
contenedor.style.fontWeight = "normal";
contenedor.style.fontStyle = "italic";
contenedor.style.textDecoration = "none";
break;
case 2: // subrayado
contenedor.style.textDecoration = "underline";
contenedor.style.fontWeight = "normal";
contenedor.style.fontStyle = "normal";
break;
case 3: // negrita-cursiva
contenedor.style.fontWeight = "bold";
contenedor.style.fontStyle = "italic";
contenedor.style.textDecoration = "none";
break;
case 4: // negrita-subrayado
contenedor.style.fontWeight = "bold";
contenedor.style.fontStyle = "normal";
contenedor.style.textDecoration = "underline";
break;
case 5: // cursiva-subrayado
contenedor.style.fontWeight = "normal";
contenedor.style.fontStyle = "italic";
contenedor.style.textDecoration = "underline";
break;
case 6: // negrita-cursiva-subrayado
contenedor.style.fontWeight = "bold";
contenedor.style.fontStyle = "italic";
contenedor.style.textDecoration = "underline";
break;
}

document.getElementById ("texto_estilo").innerHTML = estilos_textos[estilos_indice];
}
</script>

</head>

<body>

<div id="contenedor">
</div>

<br />

<form>

<input type="button" value="Alinear" onclick="javascript:alineamiento ();" />
<label id="texto_alineamiento"></label>
<br />

<input type="button" value="Tamaño" onclick="javascript:tamano ();" />
<label id="texto_tamano"></label>
<br />

<input type="button" value="Color Fondo" onclick="javascript:color_fondo ();" />
<label id="texto_color_fondo"></label>
<br />

<input type="button" value="Color Texto" onclick="javascript:color_texto ();" />
<label id="texto_color_texto"></label>
<br />

<input type="button" value="Letra Texto" onclick="javascript:fuente ();" />
<label id="texto_fuente"></label>
<br />

<input type="button" value="Estilo" onclick="javascript:estilo ();" />
<label id="texto_estilo"></label>
<br />

</form>

</body>

</html>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

RE:Ayuda Error en Javascript

Publicado por Silent88 (1 intervención) el 26/03/2008 21:10:19
Ostia gracias, muchisimas gracias eres mi idolo xD!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar