[thelist] js code trouble.

Lachlan Cannon tiedefenderdelta6 at yahoo.com
Wed Feb 20 04:53:01 CST 2002


I'm currently writing an article for ala, about extending
the style sheet switcher client side. As part of this, I
need it so that if the user has js enabled with the right
support then on submission of the form, the stylesheet is
changed and form submission is cancelled. If the browser
can't do it, or they have no js it goes to the server to
manage things. I added the following code to the style
switcher (Paul Sowden's not the more recent one), but it
doesn't work at all. Can anyone point out what I'm doing
wrong?

var styleform = document.getElementById("switcher"); //The
form has an id of switcher
function setStyleByForm() {
if (document.getElementById()) {
	var sel = document.getElementById("styles"); //The select
menu.
	var opt = sel.options[sel.selectedIndex].value;
	setActiveStyleSheet(opt);
	return false;
}
else {
	return true;
}
}
styleform.onsubmit = return setStyleByForm();

TIA

Lach

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com



More information about the thelist mailing list