Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Get input text background color?

    How do I get and check the input text background color?

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <html>
    <head>
    <title>Untitled</title>
    <script>
    function Report()
    {
    alert(document.getElementById("test").style.backgroundColor);
    }
    </script>
    </head>

    <body>

    <input id="test" type="Text" value="" style="background-Color : green">
    <input type="Button" value="Report!" onclick="Report();">

    </body>
    </html>

  • #3
    New Coder
    Join Date
    Aug 2002
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I used the style sheet with class="text_required", is it make a difference?



    <html>
    <head>
    <Title>Test Me</title>
    <link rel="stylesheet" href="edge_1.css" type="text/css">
    </head>
    <body>
    <table>
    <tr>
    <td>
    <input id="test1" name="test" size=45 class="text_required" value="" />
    </td>
    </tr>
    </table>
    </body>
    </html>

    In the stylesheet edge_1.css file where:

    input.text_required {type:text; height:19px; font-family:"Arial"; font-size:8pt; font-color:"black"; background-color:#c0dcc0; }

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    Iran
    Posts
    695
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, writing in an external file should be equal to writing for example inside the tag, and as you know the priority, I mean at first the internal, then the outer and then the external CSS will be excecuted, but in some cases as I experienced ( and I don't know why?! ) for changing a CSS value with java script or for seeing that, you have to write it as an internal value, in the code that you wrote, it perfectly works if you try to change the color by the following command :

    <script>
    document.getElementById("test1").style.backgroundColor = "#ff0000";
    </script>

    But if you try to see the current bgcolor, by alerting the value in the left side of the above line, you will see a null alert window! that I don't know why, and as I said, if you wrote at least the background-color inside the "input" tag, you could have seen that in here.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •