change styles?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • thilo

    change styles?

    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"><b r>
    ....
    <input name="targetFie ld" style="backgrou nd-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.sty le = "background-color:#ff0000"
    Elseif enter.value = 0 Then
    targetField.sty le = "background-color:#ffffff"
    Else
    targetField.sty le = "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
  • Martin Honnen

    #2
    Re: change styles?



    thilo wrote:
    [color=blue]
    > 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"><b r>
    > ...
    > <input name="targetFie ld" style="backgrou nd-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.sty le = "background-color:#ff0000"
    > Elseif enter.value = 0 Then
    > targetField.sty le = "background-color:#ffffff"
    > Else
    > targetField.sty le = "background-color:#0000ff"
    > End If[/color]

    var enterField = document.formNa me.enter;
    var targetFiedld = document.formNa me.targetField;
    var val = Number(enterFie ld.value);
    if (targetField.st yle) {
    if (val < 0)
    targetField.sty le.backgroundCo lor = '#ff0000';
    else if (val == 0)
    targetField.sty le.backgroundCo lor = ...
    else
    targetField.sty le.backgroundCo lor = ...
    }

    --

    Martin Honnen


    Comment

    Working...