Forum Moderators: open

Message Too Old, No Replies

javascript editing STYLE

how to

         

Promajo

1:05 pm on Sep 1, 2003 (gmt 0)

10+ Year Member



how do I edit a whole style sheet (+-75 lines)
by giving values in an equal number of input fields
when input fields has been changed I call a function
that reads the value from the field but I don't know how to edit the inline style sheet; I also tried to edit the style from each element (ex TD with class polltitle) by giving them each an id and with the code

document.all[str1].style[str2] = str3;
str1 = the id name
str2 = the type that has to be changed (color, width, etc)
str3 = the value from the input field

but then the names are not the same [str2] as they are in the STYLE sheet:
width stays width
background-color becomes background [i tried background-color there but it didn't worked]

what about:
border-bottom-width
border-bottom-style
border-bottom-color
font-family
font-size
....?

is there a possibility where I can used exactly the same name as stated in the STYLE sheet?

<head>
<style>
td.polltitle
{
text-align: center;
background-color: #009999;
...
}
</style>
</head>
<body>
<table>
<tr><td class="polltitle"></td></tr>
...
</table>

<input type="text" onchange="change()" id="ep1">
....

MonkeeSage

1:09 pm on Sep 1, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, Promajo!

JavaScript gets confused with a hyphen ("-") and things you mean, for example,

font-weight
font(minus)weight

But luckily most hyphenated CSS attributes can be accessed using no hyphen and capitalising the first letter of the second word, like so,

fontWeight

:)

Jordan

Promajo

10:20 pm on Sep 1, 2003 (gmt 0)

10+ Year Member



thx

works