question about putting variable in style change script

Discussion in 'Javascript' started by insideview@gmail.com, Oct 13, 2006.

  1. Guest

    How do I do something, where

    var x="-20%";

    document.all("something").style.top=x


    normally, this would work --

    document.all("something").style.top='-20%';

    but the above formulation doesn't..... is there some diff way?
    , Oct 13, 2006
    #1
    1. Advertising

  2. Dag Sunde Guest

    <> skrev i melding
    news:...
    > How do I do something, where
    >
    > var x="-20%";
    >
    > document.all("something").style.top=x
    >
    >
    > normally, this would work --
    >
    > document.all("something").style.top='-20%';
    >
    > but the above formulation doesn't..... is there some diff way?


    try:

    var x="-20%";

    document.all("something").style.top= "'" + x + "'";

    --
    Dag.
    Dag Sunde, Oct 13, 2006
    #2
    1. Advertising

  3. RobG Guest

    wrote:
    > How do I do something, where
    >
    > var x="-20%";
    >
    > document.all("something").style.top=x


    Provided the browser in question supports document.all, the above
    "works".

    Do no use document.all in isolation (or at all if IE 4 support is not
    required), use document.getElementById with appropriate feature
    detection.

    <URL: http://www.jibbering.com/faq/#FAQ4_26 >


    > normally, this would work --
    >
    > document.all("something").style.top='-20%';
    >
    > but the above formulation doesn't..... is there some diff way?


    It does work. You may not be getting the result you want, but that is
    a question for a CSS group, not here.

    news:comp.infosystems.www.authoring.stylesheets
    <URL:
    http://groups.google.com.au/group/comp.infosystems.www.authoring.stylesheets?lnk=li&hl=en
    >



    --
    Rob
    RobG, Oct 13, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jimmy Phillips
    Replies:
    2
    Views:
    416
  2. Saurabh
    Replies:
    6
    Views:
    4,529
    Chris Smith
    May 30, 2004
  3. Ken Varn
    Replies:
    0
    Views:
    448
    Ken Varn
    Apr 26, 2004
  4. Greg Hauptmann
    Replies:
    5
    Views:
    178
    David A. Black
    Jan 20, 2009
  5. torbs
    Replies:
    2
    Views:
    106
    torbs
    May 2, 2006
Loading...

Share This Page