473,796 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getElementByID

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.getEle mentById("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>
Nov 25 '06 #1
6 2117

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.getEle mentById("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

Nov 25 '06 #2
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>
Nov 25 '06 #3
David Golightly wrote:
<snip>
Also, what's going on with your HTML? Where's your
"body" tag? Where's your "html" tag?
<snip>

In HTML the opening and closing HTML and BODY tags are optional (and so
may be omitted from a valid HTML document).
... . You really need to have a
solid HTML foundation before starting JavaScript.
Javascript is not restricted only to the task of scripting web browsers.
It would be a good idea to understand HTML prior to attempting to script
a web browser's HTML DOM, but someone scripting WSH, PhotoShop or any
application that exposes an object model that can be scripted with
javascript has no reason to understand HTML first.

Richard.
Nov 26 '06 #4

Richard Cornford wrote:
David Golightly wrote:
... . You really need to have a
solid HTML foundation before starting JavaScript.

Javascript is not restricted only to the task of scripting web browsers.
It would be a good idea to understand HTML prior to attempting to script
a web browser's HTML DOM, but someone scripting WSH, PhotoShop or any
application that exposes an object model that can be scripted with
javascript has no reason to understand HTML first.
True, ECMAScript has been implemented for a variety of purposes,
contexts and platforms besides client-side HTML scripting, and I
could've qualified it, but given the OP's context and intentions
(clearly client-side HTML), why bother? Anyone interested in other
contexts already knows about them, or will find out easily enough.
What's the purpose in pointing out this trivial omission?

Nov 26 '06 #5
David Golightly wrote:
Richard Cornford wrote:
>David Golightly wrote:
... . You really need to have a
solid HTML foundation before starting JavaScript.

Javascript is not restricted only to the task of scripting web
browsers. It would be a good idea to understand HTML prior to
attempting to script a web browser's HTML DOM, but someone scripting
WSH, PhotoShop or any application that exposes an object model that
can be scripted with javascript has no reason to understand HTML
first.

True, ECMAScript has been implemented for a variety of purposes,
contexts and platforms besides client-side HTML scripting,
And JavaScript(tm) and JScript have both been server-side languages
pretty much form their inception (though server-side scripting without
first understanding HTML is not such a good idea either).
and I could've qualified it,
Rather asserted the correct subject; browser scripting specifically as
opposed to javascript in general.
but given the OP's context and intentions
(clearly client-side HTML), why bother?
So as not to inhibit the OP's appreciation of the distinction between
javascript (a general purpose scripting language) and the browser's
object model (the thing that is scripted in the web browser context).
Anyone interested in other contexts already knows
about them, or will find out easily enough.
What's the purpose in pointing out this trivial omission?
To identify the truth in a statement that was false (there is no "need"
to have a solid foundation in HTML before learning a general purpose
scripting language, while there may be a need for it prior to scripting
an HTML related object model). And to avoid the blurring of the
distinction between the language and the object morel that already has
people, for example, speaking of bugs in Safari 1.3's "javascript
engine" when no javascript bugs have been identified in Safari 1.3, just
lots of DOM bugs.

Richard.
Nov 26 '06 #6
In comp.lang.javas cript message <ek**********@c ormoran.emeteo. local>,
Sat, 25 Nov 2006 22:41:04, Winston <Cl*****@yahoo. eswrote:

><script languaje="JavaS cript">
language
>
function verifica(numero , cantidad) {
var sms = "Debe Ingresar un entero";
if (isNaN(numero)) {
document.getEle mentById("error 1").innerHTM L = "Debe
Ingresar un entero";
Don't let your posting agent line-wrap code. Posted code should be
directly executable. Your "entero" I think means "integer; isNaN does
not test for integer, but allows -2.96e+25 and Infinity.
return false;
}
if (isNaN(cantidad )) {
document.getEle mentById("error 2").innerHTM L = "Debe
Ingresar un entero";
return false;
}
else
Not needed?
return true;
}
cantidad = parseInt(cantid ad)
Try cantidad = "08".
W3's free checker TIDY, via sourceforge, gives many warnings;
http://validator.w3.org/ will probably do so too. To be sure of not
wasting time, don't post pages with invalid HTML here.

It's a good idea to read the newsgroup and its old FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v6.05 IE 6
<URL:http://www.jibbering.c om/faq/ Old RC FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Nov 26 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2708
by: lawrence | last post by:
This PHP function prints out a bunch of Javascript (as you can see). This is all part of the open source weblog software of PDS (www.publicdomainsoftware.org). We had this javascript stuff working, but it only worked for IE. You can see a working version here: http://www.publicpen.com/designer/mcControlPanel.php username: designer password: designer123 However, I've tried to rewrite this so it would work in all browsers,
12
3945
by: lawrence | last post by:
The following function correctly makes everything invisible but then fails to turn the one chosen DIV back to visible. I imagine I'm getting the syntax of the variable wrong? I've tried this with both single quotes and no single quotes, but it doesn't work either way. What am I doing wrong? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) { document.getElementById('weblogs').style.visibility='hidden';
4
5485
by: lawrence | last post by:
Can anyone tell me why this code works in Netscape 7.1 but not in IE??? <SCRIPT type='text/javascript'> function makeVisible(nameOfDiv) { document.getElementById(nameOfDiv).style.visibility='visible'; document.getElementById(nameOfDiv).style.height='auto'; if (nameOfDiv != 'weblogs')
7
5997
by: PaulB | last post by:
Good Morning everybody, I'm trying to adapt a tutorial script that will handle the behaviour of an "Expanding/Contracting" site-navigation menu. The code that seems to handle the expansion and contraction follows at the bottom of my message here. This following line is a big part of my hang-up: document.getElementById('m1').style.display='none';
3
9277
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to work on FireFox or Netscape. What could be wrong? The function: function setActiveTab(tabNo) {
1
36533
by: Andre Ranieri | last post by:
Hello, I'm trying to set up an ASP.NET 2.0 form where the user enters values in WebControls.TextBoxes for amount owing, interest and late fees and a JavaScript function totals the three values and sets the value of a label (lblTotal) to the sum of the three textbox values. The form is in a content place holder. I've added the following block of code in my form load.
4
2646
by: dr1ft3r | last post by:
Hey guys, I'm building a site for a landscaping business down the street and can't seem to get part of the code functioning correctly. The code fails on line 68 where I make a reference to an iframe's src property. Being that IE does not follow standard and considers an id, name, etc as a qualifying identifier for the document.getElementById object, I double checked to make sure that there's only one instance of id = "servif" and I never use...
13
4967
by: RommelTJ | last post by:
Hi, My website (http://www.justiceinmexico.org/indextest.php) looks good in Firefox, but horrible in IE, and I think it's because of an error in the javascript of a free web ticker I got off the internet. When I run Firebug on it, it says: document.getElementById("TICKER") has no properties TICKER_CONTENT = document.getElementById("TICKER").innerHTML; Here is the complete script:
5
5776
by: jhappeal | last post by:
I do not know Javascript that well so I might be going about this the wrong way. Any help would be appreciated. This function attempts to hide the options inside of the optgroup tag of the second select box based on the user selected option of the first select box. It works fine in Mozilla but IE7 still shows all the optgroups in the second select box. The idea is to show the appropriate list of states based on what country a user selects...
1
2240
by: vikD | last post by:
Hello, I'm really bad at javascript but I managed to get the code below to work in IE but firefox gives this error... Error: document.getElementById.formall is undefined Basically use the script to update the display to the user depending on what they choose (qty, options, shipping etc.) I'm sure it's simple but I could really use a hand. Thanks!!
0
9673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9524
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10168
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9047
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2924
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.