change styles?

T

thilo

hi ng!

i need to change the (inline) style-setting - ie the "style="
attribute - for an html-<input> by client-side script, according to
the "value" of another <input>.
i declared it like that in the html-body:

<input name="enter"><br>
....
<input name="targetField" style="background-color:#ffffff" value="Some
Text" disabled>

so i tried sth like that in the enter-field's event-handler:

If enter.value < 0 Then
targetField.style = "background-color:#ff0000"
Elseif enter.value = 0 Then
targetField.style = "background-color:#ffffff"
Else
targetField.style = "background-color:#0000ff"
End If

but this will not work.

ok, ok, thats vb-script - not javascript, but the idea is the same and
it's about handling html-objects, which have the same attribs and
props no matter what language. so, please...

has anyone an idea how to change the style?
i'm totally at sea right now and thankful for any hint or help!

cheers
thilo
 
M

Martin Honnen

thilo said:
hi ng!

i need to change the (inline) style-setting - ie the "style="
attribute - for an html-<input> by client-side script, according to
the "value" of another <input>.
i declared it like that in the html-body:

<input name="enter"><br>
...
<input name="targetField" style="background-color:#ffffff" value="Some
Text" disabled>

so i tried sth like that in the enter-field's event-handler:

If enter.value < 0 Then
targetField.style = "background-color:#ff0000"
Elseif enter.value = 0 Then
targetField.style = "background-color:#ffffff"
Else
targetField.style = "background-color:#0000ff"
End If

var enterField = document.formName.enter;
var targetFiedld = document.formName.targetField;
var val = Number(enterField.value);
if (targetField.style) {
if (val < 0)
targetField.style.backgroundColor = '#ff0000';
else if (val == 0)
targetField.style.backgroundColor = ...
else
targetField.style.backgroundColor = ...
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,093
Messages
2,570,607
Members
47,227
Latest member
bluerose1

Latest Threads

Top