You are viewing limited content. For full access, please sign in.

Question

Question

Changing the text box colour in forms when an item is overdue

asked on April 24, 2019

Does anyone know how to get the background colour of a specific field to change to 'red' if it is overdue? For example if we have something outstanding for more than 90 days I want that field to be highlighted in red.

Thanks,

Lisa

0 0

Replies

replied on April 25, 2019 Show version history

There would be a more elegant way to do this I am sure, but this is the concept.

Forms uses JQuery for javascript, so you have that fully available for manipulating the look of the form,  logic and data that is available.

You first assign a name in CSS to your field under the Layout tab ( not pictured below ).

Then you will need to write custom Javascript.

Wrap the whole thing in a document .ready function will exectute once JQuery is loaded in memory and ready to run your code.

Then you will need to grab your overdue date, I hardcoded Jan 20, 2019.. but this will be provided by some variable from the form itself.

Create a new JS date object with that date, convert it to time and store in overDueTime

get a timestamp of now in time, stored in the variable now

 

then compare.. if now is greater than or equal to overDueTime, then you want to change the text field bg to red.

Jquery provides a way to select or target specific HTML objects on the page. the selector 

$(" .overdue :text ")  reads.. use JQuery to find any html element on the page that has a class named overdue. Within all elements with class overdue, select the text input fields ( yes this would apply to multiple fields with the same class containing text fields )

Once the selector catches the right html.. then   .css("property","value")   you can change any css property..  color, width, visibility , layout, etc.

 

Hope this helps.. it's 95% there, as you can see, a fairly decent understanding of HTML, JS and CSS are required. You will still need to figure out what value you are putting in the overDueDate object. This took me about 10-12 edits before I got it functioning

To other developers.. if I have mis explained a concept or procedure here, please add your comments.

Capture.PNG
Capture.PNG (53.17 KB)
2 0
replied on April 26, 2019

I have tried the coding provided above and tried several different scenarios to try to get this to work to our needs, unfortunately I haven't been able to.

I have a 'date submitted' field and a 'original assigned' field. If they are submitting this update 90 days or more from when this was originally assigned I need the 'days outstanding' field to change to red?

Any additional help you can provide? Time doesn't matter.

 

Thanks,

Lisa

0 0
replied on April 26, 2019

Similar to the screen capture I attached, can you attach a screenshot of your CSS and JavaScript tab for the form you are trying to edit ?

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.