Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

on blur change text box colour???

  • 09-07-2002 05:08PM
    #1
    Registered Users, Registered Users 2 Posts: 706 ✭✭✭


    on blur change text box colour???

    Anyone know how to do it? That when a user selects clicks into a text box, the "class" changes to another value which has a different background colour set. I tried a view javascripts like change property in Dreamweaver MX but to no avail. Anyone know the actual script as I am not a javascript writer.

    Thanks

    Dave :)


Comments

  • Registered Users, Registered Users 2 Posts: 706 ✭✭✭DJB


    I got a nice script that does what i need above for anyone that is interested.....

    <html>
    <head>
    <script language="javascript">
    <!--
    function changeColor(obj,color){
    obj.style.backgroundColor = color;
    }
    //-->
    </script>
    </head>
    <body>
    <form>
    <input type="text" style="background-color:red;" name="itembox" onFocus="changeColor(this, 'red')" onBlur="changeColor(this, 'blue')">
    <br>
    <input type="text">
    </form>

    </body>
    </html>

    Compliments of "aegiskleais" - www.udzone.com member.

    Regards,

    Dave


  • Moderators, Social & Fun Moderators Posts: 28,633 Mod ✭✭✭✭Shiminay


    I'd have changed the class - less maintainence over time. So you'd have something like
    function changeColor(obj){
      obj.className="theNewClass";
      }
    


  • Closed Accounts Posts: 2,695 ✭✭✭b20uvkft6m5xwg


    Thx for that UDZONE link DJB

    Looks promising :)


Advertisement
Advertisement