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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Posts
    177
    Thanks
    20
    Thanked 2 Times in 1 Post

    Edit styles with input?

    Is there any way that I can have multiple textboxes where the user can enter text (such as "black or green") and it would edit a css file, like this:

    Code:
    <style>
    body{
    background-color:INPUT;
    }
    </style>
    
    <input type="text" name="bg"/>
    ?

  • #2
    Regular Coder oVTech's Avatar
    Join Date
    Nov 2010
    Location
    USA
    Posts
    296
    Thanks
    4
    Thanked 54 Times in 52 Posts
    I don't know that you can change the actual stylesheet with JS, but you can override it with a simple inline statement such as:
    Code:
    <input type="text" name="bgChange" value="" onblur="document.body.style.backgroundColor = this.value;" />
    It would be better writing a function though because then you can override a bunch of styles at the same time.




    I don't know, I don't care, and it doesn't make any difference!
    -Albert Einstein-





  •  

    Posting Permissions

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