Add (concatenate) a string to the end of a numerical field value (custom format script)?

Hello All!
1) I have a form field where a customer can input mileage (e.g. 48,000)
I would like to be able to dynamically place the comma in the proper place as well as add " miles" to the end of the value the user input.
For example:
If the user types "123456" into the field, I would like for it to display as "123,456 miles"
I assume this will require some custom format javascript... I'm familiar with the general syntax of JavaScript, but don't really know specific keywords/object names to use, I have a few custom calculation scripts in the form, and I've done some simple thing like concatenate two fields into one, etc.
But this is a little different, because I'm only working with data from one field. I tried:
event.value += " miles";
However, this causes " miles" to get added everytime ANY field changes... so I end up getting "123,456 miles miles miles miles" as the user makes changes to other fields.
2) Also, to further complicate things, is it possible to "remove" the custom formatting when the field gains focus? For example, if you use Acrobat's default number format ($1,394.00) on a field, when the user selects that field to edit the value, the formatting "disappears" so that the user would only see "1394".
I would like to achieve the same with my custom field, so when the user selected the field that displays "123,456 miles" to change the value, they would only see/edit "123456"
A bit wordy, I know, but thanks for any help!

Here's a simple way. Begin by creating a new document-level JavaScript and include the following code:
function my_format() {
    // Format number (no decimal point, comma thousands separator, etc.)
    AFNumber_Format(0, 0, 0, 0, "", false);
    // Add " miles" if there is an entry
    event.value = event.value ? event.value + " miles" : "";
function my_keystroke() {
    // Restrict entry to characters consistent with a number
    AFNumber_Keystroke(0, 0, 0, 0, "", false);
For the field in question, add the following as the custom Format script:
my_format();
and the following as the custom Keystroke script:
my_keystroke();
George

Similar Messages

  • How to add a string at the End of TLFTextField without loosing current text format!

    I have a TLFTextField that loads text from external text file.
    Then a function changes the format of some parts.
    Then as soon as I add a string at the end of my TLFTextField, All previous formatting is lost!
    I use this code to add string:
    myTLF.text += "." ;
    or
    myTLFText.text = myTLFText.text.concat(".");
    Should I use another method??

    pass the text through your formatting function again, or try appendText:
    myTLF.appendText(".") ;

  • How to add a sub report at the end of the main report whilst grouped

    Hi!
    I have a main report that is grouped by the Customers name and then details of transactions they did with the company.
    I need to add a letter at the end of each group for each customer (With their name displayed in the letter). I tried adding a sub report in the report footer, but it only appears once at the end of the report, rather than at the end of each group for each customer.
    How can I achieve the desired result?
    Regards
    Vik

    Vik,
    You are on the right track with the sub-report.
    1. Create your letter in a separate report.
    2. Add the Letter Report to your original report as a sub report in the group footer.
    3. Set the report links on the "Group By" field.
    This will give you a letter record for each report record with the same grouping as the main report.
    Hope this helps,
    Jason

  • Automatically add a current date at the end of the comments

    Hi,
    I have a form on a table with 5 fields... on one the field I am asking my users to enter comments...
    I am looking for a functionality to automatically add a current date at the end of the comments, only when they are updated or newly filled in...
    Please advice how can I do it... I am anticipating some sort of a trigger on column (when the data is modified)...
    Thanks

    automatically add a current date at the end of the comments, only when they are updated or newly filled inDo you want to add the date to the page item itself and hence show it to the end user as and when its changed, thn
    Assuming comments item is named '*P1_COMMENTS* , add the following to the "execute on load"
    $('P1_COMMENTS').change( function(){
      var d = new Date();
      $s('P1_COMMENTS', $v('P1_COMMENTS')+ d.toUTCString() );
    });If its to be done only when updating ie in the PLSQL block
    UPDATE <table name>
    SET <comments _column> = (  SELECT DECODE(  NVL(<comments _column>,'')
                                                                          ,NVL(:P1_COMMENTS,'')
                                                                          ,<comments _column>
                                                                          ,:P1_COMMENTS||TOCHAR(SYSDATE,'DD-MON-YYY')
                                                  FROM DUAL
    WHERE <condition>

  • How do you add a black segment at the end of a clip

    I would like to add a black segment at the end of my movie to lay my credits over? How is this done?
    Thanks

    Isn't there an "Over Black" in the titles pane anymore? (I don't have imovie 08...)
    Not as such. It depends on which "Title" option you are using. Double clicking on any of the last nine "Title" options in the lower area outside the text boxes will open the color selection tool. The first three "appear" to be "black" by default when "dropped" to the project area since they are actually transparent (as you can see when dropped to a video clip). Same seems to be true for "upper" area of the last nine.

  • Need to add a new row at the end of the table

    Experts,
    working jdev 11.1.1.3.0
    i am adding row programetically, my requirement need to add the row at after last row.
    i tried different ways.
    Row newLastRow = getPWBBidLaneVO().last();
    int lastRowIndex = getPWBBidLaneVO().getRangeIndexOf(newLastRow);
    getPWBBidLaneVO().insertRowAtRangeIndex(lastRowIndex - 1,
    laneRow);
    this is giving --- java.lang.ArrayIndexOutOfBoundsException: 0
    and
    http://kohlivikram.blogspot.com/2008/10/add-new-row-in-adf-table-on-button.html --- its giving index out of bound because vo.getRangeSize() is 25. We set this value at vo for performance improment suggestions.
    is there a way to add a new row at the end of the table?

    Add this to the view row impl class
           public void insertRow(Row row) {
               //go to the end of Rowset if it has rows
               Row lastRow = this.last();
               if (lastRow !=null){
                    //insert new row at the end and make it current
                   int indx = this.getRangeIndexOf(lastRow)+1;
                   this.insertRowAtRangeIndex(indx,row);
                   this.setCurrentRow(row);
               }else { // empty Rowset
               super.insertRow(row);
               }

  • Utl_file.utl_raw adds a line feed at the end of the line. How to avoid it.

    utl_file.utl_raw adds a line feed at the end of the line. I have to send some binary files to my vendor and they do not want a line feed at the end of the line.
    When I execute the sample program below, it creates a file with a line feed(chr(10)) at the end of the line. When I do dump in hexa, it shows a character x0A
    How to avoid the line feed at end of line?
    We are using Oracle 9i on unix platform.
    declare
    l_output           utl_file.file_type;
    v_raw      raw(32767);
    v_trlr_rec_code      VARCHAR2(2);
    v_trlr_evnt_title      VARCHAR2(6);
    begin
    l_output := utl_file.fopen( 'RM_MHE_IN_DIR', 'abc.dat', 'w', 14 );
    v_trlr_rec_code      := '99';
    v_trlr_evnt_title      := 'STARTD';
    v_raw := HEXTORAW(v_trlr_rec_code) || utl_raw.cast_to_raw(v_trlr_evnt_title);
    utl_file.put_raw( l_output, v_raw );
    utl_file.fflush( l_output );
    utl_file.fclose( l_output );
    dbms_output.put_line( utl_raw.cast_to_varchar2( v_raw ) );
    EXCEPTION
    WHEN OTHERS THEN
         dbms_output.put_line( sqlerrm );
    end;
    /

    oops, sorry i overlooked the fact that the db is 9i; thanks for pointing it out Solomon.
    Not sure about this, but a workaround could be to remove the "\n" characters at the end of each line using one of the many Unix utilities after the file has been created.
    isotope

  • Compressor adds a white picture at the end

    When I convert a Quicktime video exported from FCP into MP4, Compressor adds a white picture at the end of some clips.
    What I have to do is to make my video longer or shorter if I don't want this white picture (my video should stop on a still frame with a text).
    I don't know what it is due to but it's really boring because it takes me sometimes a long time to find the right length to get no white picture at the end...
    Does anyone know this problem ?
    What is the issue ?
    Thanks for your help.
    Sand

    This might be an "outpoint" issue in your original FCP file.
    (choosing the end of the last frame instead of beginning of last frame)
    See Volume II pages 101-117 of the FCP 5 PDF user manual.
    And check out this thread:
    http://discussions.apple.com/thread.jspa?threadID=574770&tstart=15

  • HT1222 hi i have a apple imac 27 2009 and i have purchased mountain lion but near the end it says An error occurred while running scripts from the package "mzps6175750011235388779.pkg"

    hi i have a apple imac 27 2009 and i have purchased mountain lion but near the end it says An error occurred while running scripts from the package “mzps6175750011235388779.pkg”
    can you please advise me what should i do to fix this

    Some ideas.
    https://discussions.apple.com/message/20034600#20034600

  • How to get the width of a numeric field at runtime

    Hi, everyone :D
    Is there a built-in that let me get the width of a numeric field at runtime? The SRW bulit in only has the SWR.GET_PAGE_NUM built-in. Is there something like the Get_item_property of Forms IN Report?
    Thanks
    Edited by: user12422762 on 07-ene-2010 14:16
    Edited by: user12422762 on 07-ene-2010 14:30
    Edited by: user12422762 on 08-ene-2010 4:40
    Edited by: user12422762 on 08-ene-2010 4:50

    Hi. Thanks for answering. I need the width because i want to set the format of the field at runtime. The quantity of decimal digits for all the numeric fieds in the report is received as a parameter.
    I can use a function to create the respective decimal mask ('D99,'D999',etc.) and then call the SRW.SET_FORMAT_MASK in the format trigger of every single field, but i'd have to type the mask of the integral part of the number in the code of the trigger ('99G999D99, '999G999G999D'). However, If i could get the width, i'd just create a function and call it from every format trigger.
    Edited by: user12422762 on 08-ene-2010 10:05
    Edited by: user12422762 on 08-ene-2010 10:06
    Edited by: user12422762 on 08-ene-2010 10:08

  • Is it possible to change the VBAP-ADRNR item address field value?

    Hi,
    Is it possible to update the VBAP-ADRNR item record field value?
    I am trying to update this field value from BAPI_SALESORDER_CHANGE but it is not changing the value.
    I am only able to change the corresponding address for that address number.
    But I need to change the address number( I want to replace with header address number) itself.
    If any ideas please let me know.
    Thanks,
    Mohan.

    ajitabap wrote:
    Hi
    >
    > Schedule Lines related Data USING BAPISDORDER_GETDETAILEDLIST Then Pass them to BAPI_SALESORDER_CHANGE Then It work and update the field.
    >
    > Regards
    > AJIT
    eh????
    What's the relevance of schedule lines and ADRNR?
    @OP: Don't. There is a reason why SAP gives out a new ADRNR. And manually changing the value of a primary/foreign key is never a good thing to do.

  • Is it possible to use the status of a checkbox to change the fillcolor of a numeric field?

    I have read through most all of the threads, but found none pertaining to my specific question.  I would like to change the fillcolor of a numeric field based upon the status (on/off) of a checkbox located on a different page.  In other words, if the checkbox is checked I want the numeric field to be yellow with a solid (thin) black border.  I have tried:
    If (CheckBox1.rawValue="1")
    {this.fillcolor="R,G,B";} else
    {this.fillcolor="250,250,250"};
    I haven't gotten the correct RGB values yet for the color I am using, that is why the script has "R,G,B"
    I am pretty new at javascript and have been learning a lot from the forums, but I just can't seem to figure this one out.  Any help would be greatly appreciated.  Thanks

    Give this a go...
    // form1.page1.cb::click - (JavaScript, client)
    if (this.rawValue == 1) {
      xfa.resolveNode("form1.page1.nf.ui.#numericEdit.border.fill.color").value = "255,255,0";
      form1.page1.nf.border.edge.color.value = "0,0,0";
    else {
      xfa.resolveNode("form1.page1.nf.ui.#numericEdit.border.fill.color").value = "255,255,255";
      form1.page1.nf.border.edge.color.value = "255,255,255";
    Don't forget to make your form a dynamic form.
    Steve

  • Add JTable Row Headers At The End Of The Rows(At Right)?

    hi all
    i got this example for adding JTable Row Headers,but it adds the headers at the left(beginning of the row)
    and i want to add the headers at the end of the row(at right),any ideas how to do that?
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.AbstractListModel;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListCellRenderer;
    import javax.swing.ListModel;
    import javax.swing.UIManager;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.JTableHeader;
    * @version 1.0 11/09/98
    class RowHeaderRenderer extends JLabel implements ListCellRenderer {
      RowHeaderRenderer(JTable table) {
        JTableHeader header = table.getTableHeader();
        setOpaque(true);
        setBorder(UIManager.getBorder("TableHeader.cellBorder"));
        setHorizontalAlignment(CENTER);
        setForeground(header.getForeground());
        setBackground(header.getBackground());
        setFont(header.getFont());
      public Component getListCellRendererComponent(JList list, Object value,
          int index, boolean isSelected, boolean cellHasFocus) {
        setText((value == null) ? "" : value.toString());
        return this;
    class RowHeaderExample extends JFrame {
      public RowHeaderExample() {
        super("Row Header Example");
        setSize(370, 150);
        ListModel lm = new AbstractListModel() {
          String headers[] = { "Row1", "Row2", "Row3", "Row4"};
          public int getSize() {
            return headers.length;
          public Object getElementAt(int index) {
            return headers[index];
        DefaultTableModel dm = new DefaultTableModel(lm.getSize(), 4);
        JTable table = new JTable(dm);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        table.setRowHeight(18);
        JList rowHeader = new JList(lm);
        rowHeader.setFixedCellWidth(50);
        rowHeader.setFixedCellHeight(18);
        rowHeader.setCellRenderer(new RowHeaderRenderer(table));
        JScrollPane scroll = new JScrollPane(table);
        scroll.setRowHeaderView(rowHeader);
        getContentPane().add(scroll, BorderLayout.CENTER);
      public static void main(String[] args) {
        RowHeaderExample frame = new RowHeaderExample();
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
        frame.setVisible(true);
    }

    fixed by:
    list.setBackground(table.getTableHeader().getBackground());here's the full code:
    import java.awt.BorderLayout;
    import java.awt.Component;
    import java.awt.ComponentOrientation;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.DefaultListModel;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.ListCellRenderer;
    import javax.swing.UIManager;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.JTableHeader;
    * @version 1.0 11/09/98
    class RowHeaderRenderer extends JLabel implements ListCellRenderer {
      JTable table;
      RowHeaderRenderer(JTable table) {
        this.table = table;
        JTableHeader header = table.getTableHeader();
        setOpaque(true);
        setBorder(UIManager.getBorder("TableHeader.cellBorder"));
        setHorizontalAlignment(CENTER);
        setForeground(header.getForeground());
        setBackground(header.getBackground());
        setFont(header.getFont());
      public Component getListCellRendererComponent(JList list, Object value,
          int index, boolean isSelected, boolean cellHasFocus) {
        list.setBackground(table.getTableHeader().getBackground());
        setText((value == null) ? "" : value.toString());
        return this;
    class RowHeaderExample extends JFrame {
      public RowHeaderExample() {
        super("Row Header Example");
        setSize(370, 150);
        setLocationRelativeTo(null);
        DefaultListModel lstModel = new DefaultListModel();
        lstModel.addElement("Row 1");
        lstModel.addElement("Row 2");
        lstModel.addElement("Row 3");
        lstModel.addElement("Row 4");
        DefaultTableModel dm = new DefaultTableModel(lstModel.getSize(), 4);
        JTable table = new JTable(dm);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        table.setRowHeight(18);
        JList rowHeader = new JList(lstModel);
        rowHeader.setFixedCellWidth(50);
        rowHeader.setFixedCellHeight(18);
        rowHeader.setCellRenderer(new RowHeaderRenderer(table));
        JScrollPane scroll = new JScrollPane(table);
        scroll.setRowHeaderView(rowHeader);
        table.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        scroll.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        getContentPane().add(scroll, BorderLayout.CENTER);
      public static void main(String[] args) {
        RowHeaderExample frame = new RowHeaderExample();
        frame.addWindowListener(new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
        frame.setVisible(true);
    }

  • How to find end of the Page in Crystal ? or I need to add one Horizontal line at the end of the page.--- URGENT HELP NEEDED

    Hi friends,
    I need to add one horizontal line  for the detail section at the end of the page.
    I tried to put that line in page footer and i tried with Box also. Both are not properly working. Some space problem is coming.
    Is there any feature to find end of the Page.
    I want report format like this.
    set id  |  set name |  date  Name
      1         x           dddd   vijay
                            dddd   sarathi
                            dddd    reddy
    (End of the page)
    Thanks in advance...
    vijay.

    Do you know how many detail records are showing up per page?
    If you do - you could create a Details B section that is suppressed except for on Record N (where N is a counter, and N is the last Detail record that will show up on a page).
    The Page footer is indeed built so that it will be rendered at the bottom of your physical page of paper.

  • BSP adds CR/LF marker at the end of the page even with compression options

    Hello!
    I'm creating normal BSP Page with Flow Logic and setting the contents myself:
    <%@page language="abap" %><%
      response->set_cdata( '-=-' ).
    %>
    The problem is that WebAS somehow always adds a CR/LF (new line) marker at the end of the page (even if I set compression option to "Remove leading and trailing spaces"). I also tried to set different mime-types.
    On the other side there is a BSP Application it00 (described here http://help.sap.com/saphelp_nw04/helpdata/en/eb/8c683c8de8a969e10000000a114084/content.htm ) that shows the uploaded file right.
    So I was trying to include that 'solution' setting OnInputProcessing event to this
    *         set response data to be the file content
              runtime->server->response->set_cdata( '!=!' ).
    *         set the mime-type and file size in the response
              runtime->server->response->set_header_field(
                name  = 'Content-Type'
                value = 'text/plain' ).
              runtime->server->response->set_header_field(
                name  = 'Content-Length'
                value = '3' ).
              navigation->response_complete( ).
    But nothing happens at all.
    Please, help me getting rid of these two annoying bytes ('CR/LF') at the end of page.

    Thank you, Cornelia!
    It works now.
    The following code is "must have"
    navigation->response_complete( ).

Maybe you are looking for

  • Need to eliminate the Zero values in the marker text in Bar chart

    Hi all, I have a requrement where i have to show the values in the BAR chart . so i have used the following syntax, <MarkerText visible="true" markerTextPlace="MTP_TOP"/> but the condition is i have to eliminate the zero value. i.e when the value is

  • IWeb and Mobile Me are exasperate me

    I have a personal web site from 2 years. Since now it was hosted at my home server. But I really want to use "comment" part of this site. I change DNS settings of my site to point to web.me.com, buy and setup a "mobile me" account, upload the site. A

  • Ora 10.2.0.4 Patch ZIP Password!

    I have just downloaded patch 8 (10204_Patch8_MSWIN-x86-64.zip) from the SAP website (https://websmp203.sap-ag.de/swcenter-3pmain) but it asks for a password to unzip! Ditto for patch 11 (10204_Patch11_MSWIN-x86-64.zip ) Is it supposed to do that? How

  • Website - Wallpaper Page Empty

    For the second day in a row I am not able to select wallpaper online at verizonwireless.com.  The page loads but is totally blank. I have downloaded ringtones just in the past couple of days so it's not my PC or login. Anyone else having the same iss

  • Help in modifying codes.

    hi, im having a problem now, lets say i have a table which contain (NAME(pk), AGE, GENDER), from program A i will insert the NAME and Age, so in the table it will be like (Tzepin, 20, GENDER), and from program B i wan to insert Male GENDER to my tzep