Background Colour of Text Box Based On Control Script Variable

Is it possible to change the Background Colour of a Text Box Based On a Control Script Variable?

For example I want to change the opacity from 0 to 100 so have a variable called [Trans]

When I change this to 100 it makes it fully white whereas 0 makes it transparent?

This needs to allow me to move the box content in preview mode as I have successfully done this using results.html(‘<"div style="background-color: rgba(255, 255, 255, ’ + Trans +’);“>’ + TextInsert + '”');

This however doesn’t allow me to move the text box in preview mode which is essential and also only changes background for the findtext variable and not the text in the box preceeding it.

Thanks

Ol

If anyone needs to do this I figured it out.

if (Laydown==“Y”) results.css({‘background-color’:‘transparent’});
else results.css({‘background-color’:‘white’});

#necromancy
This should work if more fine-tuning is needed, as was in my case:
'background-color: white; opacity: ’ + [float variable between 0.0 and 1.0]