Compare 2 fields and change color when they do not match

I have a form where I am totaling up 2 columns.  When all is said and done both totals should match, but if they don't I want to change the color of one field to red and display a message. 
Thanks,
Diane

You can use the following custom calculation script for a hidden text field. Just make sure that it is after the other two fields in the field calculation order:
(function () {
    // Get references to the two fields
    var f1 = getField("column1_total");
    var f2 = getField("column2_total");
    // Get the field values, as numbers
    var v1 = +f1.value;
    var v2 = +f2.value;
    // If the values don't match, set f2 text color to red, otherwise black
    if (v1 !== v2) {
        f2.textColor = color.red;
        app.alert("Column values don't match.", 3);
    } else {
        f2.textColor = color.black;
This will work if you're summing integers, but not if you're summing real numbers, which is usually the case. For example, this is what JavaScript calculates for the following two additions:
0.4 + 0.5 = 0.9
0.3 + 0.6 = 0.8999999999999999
This is due to the way floating point calculations are performed in JavaScript. In such a case, the code above will consider the two values to be different, even though they may display as the same value (e.g., 0.90) in the field. To deal with this, you can round each field value to a certain number of significant digits before you compare them, like this:
    // Get the field values, as numbers rounded to two decimal places
    var v1 = util.printf("%.2f", +f1.value);
    var v2 = util.printf("%.2f", +f2.value);
and that should take care of it.

Similar Messages

  • How to avoid output file and error lines when condition does not match

    Hi Experts
    A customer want to send purchase order files to several vendors and each vendor has their own requirement to content and file format. I have prepared scenarios for each vendor and a template is (conditionally) called when CardCode matches. It works fine, - PO file is generated when CardCode matches, but error lines are written to SAP B1 Control Center each time CardCode does not match the one defined in a scenario (100 or more times per day). Problem is that these error lines does not get automatic deleted. Conditional processing are made in this way:
    Result Message in SAP B1 Control Center when CardCode does not match:
    I tried to avoid an error line in SAP B1 Control Center when CardCode does not match in this way:
    Then no error lines are written to SAP B1 Control Center, but an output file is generated each time (order file when CardCode matches and an empty file when CardCode does not match).
    Any suggestions on how to avoid both errors types (error lines in SAP B1 Control Center and empty output files)?
    Or - can lines in SAP B1 Control Center be automatic deleted?
    Regards
    Steen

    Hi Steen,
    using <b1im_skip> should be the right approach, if you're working with B1 OUTBOUND.
    Following extract form the B1i help describes the usage to skip the outbound processing:
    1.1 Skipping Outbound Processing
    If you do not want to hand over the message to the receiver system, the scenario step can create a special tag that indicates to generic processing in the integration framework to skip the message processing.
    Add the following to the final transformation atom (atom0):
    <b1im_skip xmlns= ”” info=”my info” msglog=”true” msgout="yes">
    If the integration framework skips the message, it puts the message log information to the Filtered section, if the message log is switched on. The result message contains the Message skipped by vBIU logic information.
    info
    To display an individual message, define it using the info attribute.
    msglog
    If you want to avoid an entry in the message log, introduce the msglog attribute and set it to false.
    msgout
    To display the skip information in the Success section of the message log, use the msgout attribute and set it to yes.
    In case you don't want any MsgLogEntry in case of a skipped message, please enter the following in final atom0:
    <xsl:template name="transform">
    <xsl:attribute name="pltype">xml</xsl:attribute>
    <xsl:choose>
    <xsl:when test="$msg/BOM/BO/Documents/row/CardCode=&apos;C20000&apos;">
    <xsl:call-template name="transform2"/>
    </xsl:when>
    <xsl:otherwise>
    <b1im_skip info="skipped" msglog="false"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>
    Best regards
    Bastian

  • CFIMAGE error "Numbers of source Raster bands and source color space components do not match"

    I keep on getting this error when trying to upload a .JPG file. This error is not present for all jpegs, just for some of them.
    I am running CF 9 on a Windows 64-bit server.
    Any suggestions on how to modify cfimage tag or workaround this?
    Thank you!

    i have found a solution to this problem.
    first, install ImageMagick (http://www.imagemagick.org/script/index.php)
    then, detect whether or not the image is valid
    <cfset image_path = "c:\path\to\image.jpg">
    <cfif not isImageFile(image_path)>
         <cfset fixImage(image_path)>
    </cfif>
    here is the fixImage function, customize for your preferences. it essentially converts the image to a jpg format that will not throw an error with cfimage. once you run this function you can resume whatever operation you would have done with the image - IE resizing it.
    <cffunction name="fixImg" access="public" returntype="void">
            <cfargument name="image_name" type="string" required="true" />
            <cftry>
                <cfset ext = listLast(arguments.image_name,".")>
                <cfif ext eq "gif">
                    <cfset uploadedImage = ImageNew("#arguments.image_name#")>
                    <cfset uploadedImage = imageCopy(uploadedImage, 0, 0, uploadedImage.width, uploadedImage.height)>
                    <cfimage action="write" destination="#arguments.image_name#" source="#uploadedImage#" overwrite="yes">
                <cfelse>
                    <cfexecute name="C:\Program Files\ImageMagick-6.6.2-Q16\convert.exe" arguments="""#arguments.image_name#"" -strip -colorspace rgb -quality 100 ""#arguments.image_name#""" timeout="1000" />
                </cfif>
            <cfcatch type="any">
                <cfset this.err_msg = "#cfcatch.Type#:#cfcatch.detail#:#cfcatch.ExtendedInfo#">
                <cfset this.err = true>
                <cfmail to="[email protected]" from="[email protected]" subject="fix image error" type="html">
                    #arguments.image_name#<br /><br />
                    <cfdump var="#cfcatch#">
                </cfmail>
            </cfcatch>
            </cftry>
        </cffunction>

  • HT1766 I bought a sim free phone from phones 4u and had a virgin SIM card put it in to phone now it's locked to Virgin. I want to cancel and change networks but the will not give me an unlock code can you help

    I
    I bought a sim free phone from phones 4u and had a virgin SIM card put it in to phone now it's locked to Virgin. I want to cancel and change networks but they
    will not give me an unlock code can you help, as Virgin will not help me

    You did not buy an unlocked iPhone. Only Apple themselves sell unlocked iPhones in most countries. Your iPhone locked to the first carrier used. Only Virgin could authorize unlocking of your iPhone, and if they will not, there's nothing you can do. Sell the iPhone to someone who can use it with Virgin and buy a truly unlocked iPhone from Apple.
    Regards.

  • How do I get a field to automatically select a value and change color based on another automatic field?

    Here is the situation:
    I have a row on a form called Finding Risk Rating. In this row are four fields: Probability, Severity, Risk Rating, Color.
    Probability is a drop down menu with the following values: 1, 2, 3, 4, 5
    Severity is a drop down menu with the following values: A, B, C, D, E
    Risk Rating is a field that I have a custom calculation script:
    var riskRating = this.getField("Probability").value+this.getField("Severity").value;
    event.value = riskRating;
    So, when I pick Probability = 1 and Severity = D, Risk Rating will automatically change to 1D, etc. This works fine on the surface as far as I can tell.
    The part where I am stuck, is the fourth field Color.
    Ideally, I want Color to be automatically populated depending on the value of Risk Rating. For example, for 1E I would want it to say "YELLOW" and the field to change color to yellow. For 1A it would be "GREEN" with the color green, etc.
    I tried doing an if else for all cases, but it never refreshes to the correct value. I then checked using app.alert to see what fields riskRating and colorRank are (see code below), and I noticed that riskRating never changes, even though the value in Risk Rating changes. Is there a way to order script(s) so that if I execute one, the other will follow? I'm new to scripting for forms and haven't done any programming in 10+ years, so feel free to rip my code in favor or something more efficient, or direct me to a good resource I can learn from.
    Here's the basis of what I have for scripting on Color. It's brief because I wanted to test it out before writing every 'if else' statement.
    var colorRank;
    var riskRating = this.getField("Risk Rating").value;
    if (riskRating = "1E") colorRank = "YELLOW";
    else if (riskRating = "1A") colorRank = "GREEN";
    else if (riskRating = "5A") colorRank = "RED";
    event.value = colorRank;
    app.alert("colorRank = " + colorRank + ", riskRating = " + riskRating);
    Any help is appreciated. Thanks!

    One problem is if more than one combo box item has the same number associated with it, you cannot simply set the export value to the corresponding number since they need to be unique (or the user interface behaves weird). One thing you can do is set up an object to associate a list item with a value, and look up the value in code when a list item is selected.
    For more information, see: http://acrobatusers.com/tutorials/2007/js_list_combo_livecycle

  • Can anyone tell me why a picture would change color when I try to download/upload it?  It is the exact same picture- chosen the same way and when it goes to any other program it changes the color (I've tried canvas on demand and mpixpro.  I've also tried

    Can anyone tell me why this picture changes color when I try to download/upload it?  It is the exact same picture I have taken from the same location.  The image on the left is via preview and the image on the right is what is shows like when I try to download it.  I have emailed it to myself and it shows fine on the computer and in CS4, but when I look at the download via my phone or on another computer it shows the wonky color on the right.  I have checked the color space shows RGB/8 bit.  Any ideas why or how to fix it?  It isn't with any one specific session.... and I've tried it on both my desktop and my laptop- saved image to an external hard drive and to drop box.  I've tried sending the image to canvas on demand, my email, mpxipro, POST editing- all the same result.  Please HELP!!  What am I doing wrong?

    Most of the time you see something like that. The image in question has a color profile other then sRGB. Some image viewers/displayers are color managed and others are not.  So the image do not look the same in all of the applications you use. So colors seem to change.
    Try converting it to sRGB color and see if then looks the same all around. Also I think PC and Mac displays are set to different gamma something like 1.8 and 2.2
    Though I'm colorblind I even see color variations.

  • How do i get my events to change colors when i add new ones in my calendar

    How do I get my events to change colors when I add a new event in my calendar?

    When you add an event and you see the heading "Calendar", do you see a name to the right of it such as "Work"?  If you tap on the heading "Calendar" does it show you a list of calendars?
    I'm basing this on my experience using iCal on a Mac to sync with my iPad.  I created a number of calendars on the Mac and assigned them different colors.  Those appear on my iPad.  I don't know how to create additional calendars on the iPad alone - I must create them in iCal or MobileMe then they show up on the iPad.  Are you using a Mac or MobileMe?

  • I need help highlighting an expiration date on my Numbers '09 spreadsheet. I want the text/fill of a cell to change color when the expiration date of an item is within 180 days of the current date.

    I need help highlighting cells on my Numbers '09 spreadsheet.  I want the cell text/fill to change color when the date is 180 days or less from the current date.  I already have a cell with the current date in it.  I also know how to change the fill/text colors.  All the cells have been formatted to show date only.  I am having trouble with the formula.  I can get to the Conditional Formatting menu and select "With Dates" but after that I am lost.  Can anyone help?
    Thank you for any assistance.
    B

    Set a Conditional Format rule as shown in the illustration below. The rule has been applied to all dates in column B of the table.
    Regards,
    Barry

  • PS file in illustrator changes color when I move it??

    When I open a ps file in illustrator some objects change color when I move them and are displayed correctly in preview and Photoshop, why and how do I fix this?
    Also the object seems to be duplicated. It should have the same and only the colors of the scale bar. In another file the image part is correct and the scale bar is incorrect.
    Should look like this:

    It is an odd problem. The "good" screen shot is from opening the PS file in mac's preview. As it is, I use several tools in illustrator to get the final image where I need it to be; several layers and what not. I have tired 5, 5.1, and 6 with the same problem. Again I have a different problem when I use a different figure:
    As you can see just the opposite problem is the case. The map part is good while the color scale if off. Both parts are made in the same way and more or less in the same sequence, I don't think it is purely a problem at birth and other software can "see" it correctly, so I don't think it is a hardware problem.  

  • Photos Change Color When Published

    Good morning,
    Wondering if anyone might be able to advise me on why the colors of my photos appear washed out when I publish my iWeb page to a folder. When I open the page in Firefox the colors are not as vibrant and saturated as when they are in iWeb. Would this have anything to do with iWeb compressing the photos when publishing to a folder?
    All photos have been added to iWeb as jpegs.
    Thanks for your time.
    Cheers,
    John

    John:
    How do the photos look with Safari? I vaguely remember a thread which mentioned that Firefox didn't manage color and Safari did or something to that effect. What is the color profile in the photos (sRGB is preferred for web use) and do you have iWeb setup to optimize photos upon importing?

  • WOT and Webutation is showing as disabled when they are not

    WOT and Webutation is showing as disabled when they are not .The icons show,but no color on icons. Says WOT is disabled when its not. Also the same on Webutation. Tried uninstalling then reinstalled both and the same thing happened. Tried Wot on another users account and theirs work. Can someone help me on these issues?

    capaho wrote:
    That's like saying a boat is an airplane because it's not a car.
    SMH
    In other words, how does your explanation account for ED (enhanced definition)?
    ED is generally considered to be 576p or 480p, but this is not universally accepted and these resolutions are often accepted as HD also. Additionally an ED signal uses non square pixels just as SD does so the horizontal pixel dimensions should be no more than 720. Exactly how the tv would treat these resolutions I don't know (yet).
    If you have a copy of the source code for the function that displays the HD icon, please post it so I can take a look at it.
    Why should I have such a copy and why is it relevant. The issue here is that the OP believes his video is incorrectly labelled HD which is not the case. There may or may not be anomalies in the way the tv attributes the HD label to some files (although it isn't the case for me), however the OP has incorrectly converted his source video and they are no longer SD, they are also not ED by whichever definition you wish to apply and any such anomalies should they exist are not responsible for the OP's files being labelled HD.

  • When I convert my pdf doc to word, the fonts go really weird and it also puts some text into boxes. when I try to select the test and change the font, it does not change it properly?

    When I convert my pdf doc to word, the fonts go really weird and it also puts some text into boxes. when I try to select the text and change the font, it does not change it properly? This is making it impossible to amend.

    Hi Janedance1,
    If the PDF that you converted already has searchable text, please try disabling OCR as described in this document: How to disable Optical Character Recognition (OCR) when converting PDF to Word or Excel. (If the PDF was created from a scanned document and doesn't already have searchable text, disabling OCR isn't a great option, as the text won't be searchable/editable in the converted Word doc.)
    Please let us know how it goes.
    Best,
    Sara

  • My ipod 5th gen won't change volume when headphones are plugged in, but when they are not I can change the volume on the speaker.  How do I fix this?

    My ipod 5th gen won't let me adjust volume when headphones are plugged in, but when they are not I can adjust the volume on the speaker.  How do I fix this?

    Try a hard reset of the Nano. To do this, press and hold both the Select (Center) and Menu buttons together long enough for the Apple logo to appear.
    I assume you have double checked to make sure you are plugging the headset all the way in meaning the white part of the headset is flush with the body of the Nano?
    B-rock

  • I have dragged 2 files to the trash bin but I cannot delete them from the trash bin. It keeps telling me these files are in use when they are not. How do I delete these files? One is a txt file and the other is an xls file

    I have dragged 2 files to the trash bin but I cannot delete them from the trash bin. It keeps telling me these files are in use when they are not. How do I delete these files? One is a txt file and the other is an xls file

    From the Finder menu select 'Secure Empty Trash'. If this or the suggestion above doesn't resolve the problem take a look at the various suggestions in this link:
    http://www.thexlab.com/faqs/trash.html

  • Link in form of a pictrue - change color when sweeping

    Doing links in form of a word which change color when sweeping over them is simple in iWeb.
    I wonder how I do if I not just want the color of the text but also an image to change.
    Ex. I have a link in form of a bright cloud. When one sweep the mouse over it I want the cloud transform into a darker form of the same cloud.
    Perhaps I need a codescript which connect two pictures of the cloud?
    Johan

    Johan:
    It's called a rollover. There are a number of topics on the subject in this search result page: http://discussions.apple.com/search.jspa?threadID=&q=ROLLOVER&objID=&dateRange=l ast90days&userID=&numResults=30&rankBy=10001. It's done with an HTML Snippet. One of the topics may have an answer for you.
    OT

Maybe you are looking for

  • Create multi-page printable pdf w/CS3 Photoshop

    Is this possible to do without downloading additional plugins/shareware in PS CS3?  Here's the deal... it's just a recipe I downloaded that was way too small to read easily. Ignorance to the rescue!  After enlarging the text, I split it into two PDF

  • How to shuffle photos when creating a slideshow?

    When I click the slideshow button on an album I have the option to shuffle photos, but do not have the same option when I create a slideshow. I want to save the slideshow; can I save a slideshow played after using the slideshow button? Or how can I s

  • C6180 All In One Printer only prints 1 page per document after Windows 7 64 bit upgrade

    I loaded the software for my Photosmart C6180 all-in-one printer as part of a computer upgrade from Windows XP to Windows 7. My printer is networked and everyone else in the house can print to this printer with no problem. However, whenever I try to

  • LDAP user not found when authenticating

    In the next episode of my LDAP sync struggles, I am not able to authenticate any user when LDAP authentication is set. The user data is synching fine through the Active Directory, but when attempting to log in I get the "Incorrect User Name or Passwa

  • Sending URL requests

    I keep seeing large spikes in my swf trying to send a url request. But these only appear in Firefox in OSX. I haven't tested in windows. Chrome (pepper and regular) and safari both work fine.  Also see large spikes when using extrnal interface. Any i