[thelist] NS 4 / 6 & IE 5 DOM
Andrew Forsberg
andrew at uber.net.nz
Thu Apr 26 00:08:03 CDT 2001
Hi All,
After having taken a one year holiday from !@#!%@#^ javascript (right
now my brain is too exhausted to even attempt to find the right
expletives -- and yes, it's my memory I'm really blaming, not the
language) I'm having a lot of trouble finding a simple and elegant
way to use NS 4 (document.....) and 6's dom
(document.getElementById(....)), as well as IE 5's
(document.all......).
If it's at all important: I want to set and change the 'display'
attribute of a couple of divs, which chokes on NS4, but I suppose I
could probably work out something with the 'visibility' attribute.
So... if somebody could sharing their amazing multi-browser dom
routine with me I would be endlessly grateful!
<tip type="basic php" author="andrew">
If you have a fairly long list of possible values for a variable in a
switch or if-elseif-elseif-...-else structure you might save your
brain and eyesight some trouble by using an array in its own routine.
For example, rather than:
if ($id=="0")
{
name="blah0";
}
elseif ($id=="1")
{
name="goober2";
}
etc etc etc
You could bung the whole lot in a routine:
function get_name($id)
{
$name_array = array
(
6 => "blah",
9 => "bung",
4 => "foo",
2 => "and",
7 => "bar",
);
return ($name_array[$id]);
}
</tip>
--
Andrew Forsberg
uberNET
http://www.uber.net.nz/
More information about the thelist
mailing list