tags:

views:

57

answers:

2

Possible Duplicate:
Changing a CSS rule-set from Javascript

Dear experts,

Is there a way to dynamically generate a CSS stylesheets using Javascript according to what the users fill in on a form (user interface)?

If this isn't possible with Javascript, could someone point me to the right direction. Ruby on rails would also be fine.

Thanks

+1  A: 

Yes you can do that.. Lets say you have a input fields.. and whenever user changes value in the input field, then you want to add some special css..

 $('#form input').change(function(){

     $('#someElement').css({
              background-color: green;
          });
 });
kapser
+1  A: 

Sure you can. But you have to validate the user input. And write some kind of a css-processor to search the input text for the elements themselves and the according css-rules.

Finding css-rules is easy - they are all inside the braces {...} and the elements to which you apply the rules are outside the braces {...} .an .element {...}

You'll end up with something like this css playground

angryobject