Formatting in JavaScript

I use the following in a validation event

var MBn = (iSizeN / 1383.27)/ 1024;

The result is a figure with about 10 decimal places.

(1) what should I do so that the result is only 2 decimal places?

(2) how then convert the number to 2 decimal places to a text string so that I can use it in a message? Note that I still need access the MBn then the variable string variable would be MBs.

Thank you very much for the help.

2. is easy, you don't need to formate it...


Textfield1.RawValue = "Text1" + Math.round (MBn * 100) 100 + "Text2";

For the first question:

To tell the truth I don't know if I had your problem.

MBn = Math.round(MBn *100)/100

MBn has two numbers then.

Only the 'event' you put in feels somehow... strange to me.

Tags: Adobe LiveCycle

Similar Questions

  • format of JavaScript in week

    I have the JavaScript in a form I created in LiveCycle.  The first, defining the ReportDate element works fine.  The second element does not work.  He puts eeee in the field and not the day of the week name.  I even tried to use 'EEA' and 'EEEE' and 'EEE' to get only the characters of 'e' placed in the field, because they are listed. I could be wrong?

    Form1. #pageSet [0]. Page1.SaveAsButton::click - (JavaScript, client)

    Place the Date and the current date into the appropriate fields of the form

    Page1Header.reportdate = util.printd ("mm/dd/yyyy", new Date());

    Page1Header.ReportDay = util.printd ("eeee", new Date());

    Kind regards

    Karl

    You mix JavaScript with FormCalc keywords.

    EEEE - is a keyword of FormCalc to get the day of the week.

    In java Script, you can get the days of week number.

    If you need to write code to get the match statement of name for the day of the week.

    Try something like this...

    var d = new Date();
    day of week var = new Array (7);
    day of week [0] = 'Sunday ';
    day of week [1] = "Monday";
    day of week [2] = "Tuesday";
    day of week [3] = "Wednesday";
    day of week [4] = "Thursday";
    day of week [5] = "Friday";
    day of week [6] = "Saturday";

    xfa.host.messageBox ("Today is" + weekday [d.getDay ()]);

    Page1Header.ReportDay.RawValue = weekday [d.getDay ()];

    Thank you

    Srini

  • What is the format of javascript in the SCRIPT processor?

    Dear,

    I'm trying to divide the amounts of the two columns by using the script processor (because the divide processor is able to divide by a number 1,2,3,...).

    I tried below scripts and many variations, but it does not work.

    Could someone please help?

    I chose two attributes of the available attributes (the columns are called NewNumber.2, NewNumber.1).

    In the options tab of the, I wrote this script, with the result type digital.

    The output attribute column is called result.

    var x = "NewNumber.1";

    var y = "NewNumber.2";

    var z = 'result '.

    z = x / y;

    Thank you!!

    Just use an expression with the processor of the Expression, for example

    @ "Attribute 1"/@"Attribute 2.

  • Javascript code formatting

    Is there an easy way to format the JavaScript in an identity document, kind of like this forum formats the code below? I think to put together a guide on writing scripts and want to use the living text, but have it formatted rather than screenshots of ESTK.

    var doc = activeDocument;
    var base = doc.activeLayer;
    
    
    for(var i = 0;i>-11;i--){
        doc.activeLayer = base;
        
        var idCpTL = charIDToTypeID( "CpTL" );
        executeAction( idCpTL, undefined, DialogModes.NO );
        
        desat (i*10)
    
        }
    
    function desat(val){
        var idvibrance = stringIDToTypeID( "vibrance" );
            var desc4 = new ActionDescriptor();
            var idStrt = charIDToTypeID( "Strt" );
            desc4.putInteger( idStrt, val );
        executeAction( idvibrance, desc4, DialogModes.NO );
    }
    

    Hey Chuck Uebele

    You can use simple 2 paragraph styles.

    Have fun

  • How to export the Indesign to Format XML using JavaScript document

    Hi all...

    Can someone help me, how to export the indesign document to XML Format using JavaScript...

    Thanks in advance...

    doc.exportFile ( ExportFormat.XML, File(Folder.desktop+"/doc.xml" )
    
  • Countdown is not running

    Hello

    I am incorporated the countdown on the Web site for 30 days only, how can I optimize the code. Script is given below

    WEB SITE

    < script >

    {$(document) .ready (function ()}

    Reminder works only with the direction = "low".

    $('.flipTimer').flipTimer ({direction: "down", the date: "November 25, 2015 08:30:30 ', callback: function() {alert ('times up!') ;}});}"})

    });

    < /script >

    When you use the 'down' direction, the date must be in the future. In addition, the date must be in a format that JavaScript can understand. Using jj/mm/AAAA will not work. It must be in the format mm/DD/YYYY. For example, this will create a countdown for Christmas:

  • SaveAs PBM

    Hello.

    I need to save my current active document under a PBM format via javascript CS6 file.

    However, I'm running on the problem there is that no object PBMSaveOptions feel like I can go to the Save as function.

    My output always gets transformed into .psd even though I defined a .pbm extension.

    Anyone know if I need to create a custom options object or something else?

    Bottom line: it may not be enough objects SaveOptions to cover all Photoshop formats can save through the user interface.

    The Javascript reference lists these:

    BMPSaveOptions

    DCS1_SaveOptions

    DCS2_SaveOptions

    EPSSaveOptions

    GIFSaveOptions

    JPEGSaveOptions

    PDFSaveOptions

    PhotoshopSaveOptions

    PICTFileSaveOptions

    PICTResourceSaveOptions

    PixarSaveOptions

    PNGSaveOptions

    RawSaveOptions

    SGIRGBSaveOptions

    TargaSaveOptions

    TiffSaveOptions

    Thanks for any help.

    Len-

    Well, I did some tests.  Just put the name of the file that you want after the path name:

    desc2.putPath (Marie-Salomé, new file ("C:\\Users\\len\\Desktop\\MyFile.pmb"));

  • Number shaped Non-Database components

    If an element represents a column of data, the format on the 'Settings' tab mask works. But if the item is not a database column, the format mask will not apply.

    How can I format numbers in the page elements that do not represent database columns?

    I am not the expert in javascript, but here's an example that I used to load the text in a line in the form of a number and perform a calculation and load the result to another column. It does include formatting in JS, but maybe it'll be useful.

          var nXtbuy =  parseFloat($(this).closest('tr').find('.base_next_buy_hid').text());
          var cRslt = (nXtbuy + (nXtbuy * parseFloat($v('P85_PERCENT'))/100));
          cRslt =  Math.round(cRslt*Math.pow(10,parseFloat($v('P85_ROUND'))))/Math.pow(10,parseFloat($v('P85_ROUND')));
          $s('f02_'+vRow, cRslt)
    
    The parseFloat is the significant piece there to avoid NaN
    

    Then, if you google "formatting in JavaScript", a number of good entries search there are several.

    Published by: Bob37 on May 11, 2012 12:15

  • Numbers with decimals and text in a field

    Hello all, I have created a form to fill out pdf for use as a budget calculator. Many of the fields require the word "(reserved)" to be entered in the field, if there is no value. If I set the format of the number field, I can't type all the letters in the field. If I set the size to zero, I can type the numbers and letters, but it will not calculate if the numbers have commas and decimal points. Any ideas? Thank you!

    OK, something that will work is to add two functions to a JavaScript script at the level of the document:

    function reservedFormat() {}

    AFNumber_Format (2, 0, 0, 0, "", false);

    If (! event.value) event.value = "(reserved)".

    }

    function reservedKeystroke() {}

    AFNumber_Keystroke (2, 0, 0, 0, "", false);

    }

    Then set up the field with a custom Format and JavaScript typo that represents (respectively):

    Custom format JavaScript

    reservedFormat();

    Custom keystroke JavaScript

    reservedKeystroke();

    Here is an example of PDF file that demonstrates this: https://acrobat.com/#d=VCzfhUuUgB1GW2XQAh6Zyg

    That this fact is to use the same built-in routines that Acrobat uses when configure you a number format, but add the bit that displays the string "(reserved)" when the field is empty. This is done in the Format script since you just want to display this value and do not it field value when the field is empty. Note that if the value of the field is zero, it will appear not "(reserved)".

  • Export of values vs. null empty

    I created a form with a Submit button that generates an email with the form of an attachment. The problem is that if there is an empty field, the e-mail contains the value "null" where I want to remain a Virgin. Question: How can I format the JavaScript below to let the empty fields remain blank in the email and not display as "null". ?

    SubmitNulls.png

    Questions of syntax, the main issue is you have = + (which is assignment) instead of += (which is concat). A correct should be +=

  • Cursor move to the field next when you press enter/return

    Is there a way to make the curson go to the next field when you click Enter / return as it does when you press the tab key? Currently he entered just the info in the current field and does not advance to the next field with I button back.

    You can with JavaScript, but you have to use in the event of strike or Format a field, which is (normally) not available for all types of fields (checkboxes, for example). For text fields, you can use the following in the Format event JavaScript code:

    Fragment of script format for the text field

    If (event.commitKey = 2) {}

    getField("Text2").setFocus ();

    }

    Replace "Text2" with the name of the field you want to access the next.

    The problem with this approach is the Format or the key event isn't available for the fields for which you have selected one of the pre-defined formats types (for example, number). There are ways to work around this limitation, if necessary, but things get a little complicated.

  • ColdFusion and Flex

    Before the question, I want to give a bit of history.

    I started using DreamWeaver and Coldfusion to create simple applications for our employees to use. It started with simple applications that the end user entered data. After several years, I learned to integrate several systems (such as emails, accounts payable and our main software in this first site.) He slowly turned into this huge, disjoint site which doesn't have any flow to it.

    About 3 months ago I started to go through the whole site, and using css, I gave him a universal theme. I still don't like the look of it, it still feels disjointed. I started, last week, reading about Flex, but I'm not really a few things.

    I want to create a Web site that has a universal theme, is nice to look at, easy to use and is dynamic...

    Is that what I was looking for Flex?

    Someone at - it large Internet sites, using Flex, examples?

    Any advice on this would be greatly appreciated.

    In fact, I'd keep the coldfusion server. Basically write you your components in ColdFusion and call them from Flex. So you would create a remote procedure in flex that calls your CFC and it would return a query to tell employees etc. This marriage you gives the most flexibility because you can have everything you need available to Flex CF via your CFC. And if you're lucky, you have created your ColdFusion to migrate using CFC application, so you can reuse them.

    The extent of the Apollo. Apollo is a totally new environment to create rich applications. The palyer Apollo is much more functional that it allows for system access, format PDF, Javascript, HTML etc. So, if you are limited by Flex and you can use Apollo. However, this requires the application installed on the client computer. Not much, but Apoolo is very powerful. Check it out.

    Al

  • JavaScript to display the field date in the format below

    I'm a customer form who need the date to display in the format below

    As if he puts day 13/05/2015 then it should show that may 13, 2016 (Please note that there should be "th" after 13)

    19/07/2016 should show that July 19, 2016 (an' th' after only 19 should be here)

    Thanking you

    This way of listing of numbers is known as "Ordinal". There are many was to this script. What works for the web that JavaScript can easily work with few changes in Acrobat Forms. This type of date format is generally used in legal forms.

    You should be able to search the forums for "legal date" or "ordinal" and find the post.

    I found a JavaScript function that can take a number of entry and returns the number with the ordinal suffix. This allows you to create any number of date formats.

    This function is not limited to a few dates bat can be used to add the ordinal suffix to a number any.

    The function:

    function ordinal_suffix_of (I) I have

    {

    var j = i % 10, / / tens of rest

    k = i % 100, //100's remains

    cSuffix = "e"; results of default suffix

    If (j == 1 & k! = 11) {}

    No 11;

    cSuffix = "m";

    }

    If (j == 2 & k! = 12) {}

    No 12;

    cSuffix = "nd";

    }

    If (j == 3 & k! = 13) {}

    No 13;

    cSuffix = "rd";

    }

    return i + cSuffix;

    } / / end of function ordial_suffix;

    I put this code in the location of the script to document level and then call it as necessary in the various areas.

    I enter the date in a different area that would not print and then have the date formatting in another area. You know how to divide the date entered in the month, string date and year, parts and then rearrange them as needed.

    You can test the code using the Acrobat JavaScript console:

    function ordinal_suffix_of (i)
    {
    var j = i % 10, / / tens of rest
    k = i % 100, //100's remains
    cSuffix = "e"; results of default suffix
    If (j == 1 & k! = 11) {}
    No 11;
    cSuffix = "m";
    }
    If (j == 2 & k! = 12) {}
    No 12;
    cSuffix = "nd";
    }
    If (j == 3 & k! = 13) {}
    No 13;
    cSuffix = "rd";
    }
    return i + cSuffix;
    } / / end of function ordial_suffix;

    function MyDateFormat (cFormat, cDate)
    {
    Kai var = util.scand (cFormat, cDate);
    if(oDate == null)
    {app.alert ("invalid date provided", 1, 0);}
    }
    on the other
    {
    "Return util.printd ("mmmm", letter) +" "+ ordinal_suffix_of (oDate.getDate ()) + ', ' + util.printd ("yyyy", anyway);"
    }
    }

    var dateInput = "13/05/2015; value of date entered;
    var cFormattedDate = MyDateFormat ("d/mm/yyyy", dateInput); formatted string for the date;
    Console.println (cFormattedDate);
    dateInput = ' 23/05/2015;
    Console.println (MyDateFormat ("d/mm/yyyy", dateInput));
    dateInput = "19/07/2015;
    Console.println (MyDateFormat ("d/mm/yyyy", dateInput));
    dateInput = "09/07/2015;
    Console.println (MyDateFormat ("d/mm/yyyy", dateInput));

  • Stimulant of the button with javascript under a button in pdf format

    Hi all

    Is it possible to stimulate using acrobat javascript or javascript livecycle @under a key press button?

    For ex. I click on a button and who work as Atl + F (File menu) or win + R (run box) under windows.

    Hope this is clear.

    Thank you

    Arvind

    LiveCycle Designer uses the same JavaScript engine that Acrobat and Reader when the LiveCycle form is in PDF format. So, as stated in the form Acrobat JavaScript, the JavaScript engine and capabilities. As explained in the Acrobat JavaScript forum, JavaScript used in Acrobat or Reader is the willingness to 'sand' or very isolated from the JavaScript of your computer program. This was done to protect users of form Acrobat or Reader to run malicious code.

    It might be possible if you were writing a plugin add-on using a computer program have complied and the information provided in the Acrobat SDK kit. You must manually install this program on your system. For others to use the code, you will need to register as a developer with Adobe and have each user to install the code on their system at their own risk.

  • Hi, I want to add a link back to a button in the muse. Any ideas? thinking that I'll have to add the following &lt; a href = "javascript:history.back ()" &gt; &lt; /a &gt; and return code in a text editor by hand after I exported the site in html format.

    Hi, I want to add a link back to a button in the muse. Any ideas? thinking that I'll have to add the following < a href = "javascript:history.back ()" > < /a > and return code in a text editor by hand after I exported the site in html format.

    No need to code the hand something to do.

    Create your button or link just as you would for any button or link.

    Click on your button

    In the hyperlinks tool simply add javascript:history.back()

    Press enter

    Fact...

Maybe you are looking for

  • ProBook 470 G0 network controller drivers

    Hello. I have trouble with the drivers for the network for ProBook 470 controller. After the installation of new windows no driver does not match this device. Help, please.

  • WRT160N wireless connection instability.

    It's long, so I'll try to keep it short. Research, I see there is a problem with the current firmware of hardware v2, but that doesn't apply here.  I am hardware with Firmware 1.02.2 v1.  I see also several other posts with connection problems to the

  • E3000 displays "USB is not supported" error with external hard drive

    I have the E3000 router and recently bought a USB WD (Western Digital) 2 TB external hard drive.  I plug the HDD on the router, open the home page of the router (http://192.168.1.1/) then click on storage > disk and I get an error of "the USB is conn

  • CSCuv73286 - update VMware ACS 5.5 to 5.7

    Fearly disappointed with Cisco ACS team development, there are still problems with the upates (as it always has). I see in the support tools that this bug was listed as status: fixed. It has not listed 'released fixed' and describes the Bug, only a w

  • Get the session state of the order of the day in javascript

    Is there anyway to get the value of an element of demand through jS?[I have an app that loads a different source into an iframe depending on which page the user is.]  I can load this value in session state for a part of the application (or a point pr