No announcement yet.

Dynamically Setting Form Styles

  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamically Setting Form Styles

    The macro "sc_field_style" gives us the ability to change grid styles during events, however it doesn't work for forms.

    How do I change field styles on a form?

    It doesn't really make much sense that this only works for grids, but not forms.

    -Thanks for any advice.

  • #2
    Yes you are right. But it's fairly simple to do that using javascript. If you google this forum then you will find much samples. One sample can be found here:
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development /


    • #3
      I've actually found this example before, but it doesn't seem to do anything. I created a php method called coloration() which contains the following code:

      $field = 'OrderStatus';
      $color = 'red';
      print "In color.";
      if({OrderStatus} > 5)
      	$color = 'green';
      I put the coloration() method in my OnLoad event like the forum suggested. Then I created a javascript method with 2 input paramaters and the following code:

      document.F1[field].style.backgroundColor = color;


      • #4
        Alright, so I found out why it wasn't working. Apparently the field name must be lowercase, despite the field name having capitalized letters in the development environment. Once I changed the field variable from OrderStatus to orderstatus, it worked!


        • #5
          It's not working in situation when i want change color of field in multiple rows detail form in master/detail form


          • #6
            This is very close to what I need to accomplish... the only issue I have is that I need the conditional code to be in the event based on data I am reading out of the database.
            Would it be possible to use this method to create a PHP Method that you could call with values of "field" and "color" so I could change any field to any color within the events on a form?

            Edit: Actually I could put my database lookup code in the method itself.... but still the question remains... could the above be done? It might be very handy.