Computed looking/acting text fields

Ever wish you could use a Notes computed field but you are using JavaScript to do your calculations? Fear no more, here is the solution.

1) Put a (CSS) style sheet at the top of the page (cut/paste (a) from code below) and make it pass through HTML.

Create your field that is to be calculated using a JS function. Make it Text and Editable. Then go to the HTML tab for the field and in the Style section put "border=0" without the quotes. Then in the Class section put "computedFld1" without the quotes.

Then replace the "CornflowerBlue" in the CSS with whatever color you are using as your background. A great site for converting hex to rgb and reverse is: http://www.yvg.com/twrs/RGBConverter.html

Then, to make sure that the field will not be edited, in the onFocus event for your field, put the code from section (b) below. If someone tries to enter the field, they will be redirected to the other field.

Your field will not have borders, it will calculate when you run your JS functions/calculations and no one can edit the field manually. Tadaaa. Looks and works just like a computed field, just for Javascript!

Enjoy!
Mike


(a)

<style type="text/css">
.computedFld1 
{ 
background-color : CornflowerBlue;
}</style>

(b)
document.forms[0].ANOTHER_FIELD_NAME.focus();

This was first published in November 2001

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.