Hello, I want to change the background color of a form field dynamically. How can I do this???
Thank you Albert for your answer,
but it does not work for me. There is no change of the background color visible.
I discover that the described solution works with control apps but not with form apps. In form apps nothing happened. Is there any solution.
Best regards.
HANS
Why dont you use a css with a different background color for that form?
Hello rr,
thank you for your answer. I want to change the background color of a field depending on the the state of variable.
Best regards
Hans.
Yes, but the answer is to invoke some javascript. You can use jquery for that:
$(document).ready(function() { $('input:text').focus( function(){ $(this).css({'background-color' : '#FFEEE'}); }); $('input:text').blur( function(){ $(this).css({'background-color' : '#DFD8D1'}); }); });
This applies to all formfields, but you can find out the fieldname technically and apply the correct code. There’s a sc macro to call a javascript routine.
Sorry but inserting code doesn’t work on this forum too.
Hello Albert,
I have not been busy by myself with jQuery. So I can not read the malformatted code snippet. Can you write it as normal text not as code???
Thank you
Hans.
Why did Javascript only work correctly in blank or control forms?
@onmountain This is excellent… Thank you! Working perfectly for my needs. I was able to adapt this to actually reading the field names out of the database and looping through them to color the ones I needed dynamically based on another table of which fields are required.