Adding (or divide, multiply, etc.) in the text field values

Hello world

I'm trying to calculate values in fields of text entered by the user (who didn't accept numbers) as well as the values selected by the user drop-down list boxes. I have a function to a button:

reviewQ.calcBtn.addEventListener(MouseEvent.CLICK, calcAns);
function calcAns(e:MouseEvent):void
{
     reviewQ.calcAns_text.text = "Your calculated result is " + parseInt(Q1.Q1_text.text) + parseInt(Q2.Q2_cb.selectedItem.data) + parseInt(Q3.Q3_text.text) + parseInt(Q4.Q4_cb.selectedItem.data);
}

Now, all I get is the actual values entered into the text fields and selected in the drop-down list boxes. How can I get the sum of these values to display on my 'calcAns_text.text '?

Thank you for your help,

Rafa.

You have to build your own filtering for values.  If you think that decimal values, then you will need to plan and test for the presence of a comma in a numeric string and then do not use parseInt(); (what creates an integer value), but use instead Number();  You will need to filter the commas in the numbers in the string before creating the value used for the calculation.

Tags: Adobe Animate

Similar Questions

  • Getting the text field value?

    How can I get the value entered into the field of action tf_1?

    Let's say I'm going to number 5 in the text field tf_1, how can I receive it for use in the code?five.png

    I would like to store that value in the variable, so that I can work with him in a function.

    Can someone help me? I am already grateful!

    var num:Number;

    calcular.addEventListener (MouseEvent.CLICK, resolver);

    function resolver(Event:MouseEvent): void {}

    NUM = Number (tf_1.text);

    If (num/400 = 0) {}

    trace ("Yes!");

    }

    }

  • Text added to the text field using the variable does not appear

    Hello

    I have a test field I created dynamically.  If I add some text to it by writing: myField.text = 'text', the text if poster, but if I add text using a variable is nothing.  If I trace trace text in the text field ("text =" myField.text) get good value.

    Someone at - it ideas?

    Best regards

    Chris McLaughlin

    Try to comment out the two lines below and see if it helps...

    ["textField" + guestCueCnt 'c'] .defaultTextFormat plus myFormat;
    ["textField" + guestCueCnt + 'c'] .embedFonts = true;

  • Problem of text selection in the text field for entry in the emulator

    I'm having a problem of text selection in a text field when I run my application in the emulator Playbook. Let me see if I can expose the problem here:

    1. The field in question is a classic text, text with an integrated in police entry field. The domain is in a SWC and referenced in another FILE.
    2. The code is set up such that when a user clicks the field function is called to highlight all the text. The code is more or less as follows:
    thisField.addEventListener(MouseEvent.CLICK, onFieldClick);
    
    private function onFieldClick(event:MouseEvent):void
    {
       var selectedField:TextField = event.target as TextField;
       selectedField.setSelection(0, selectedField.text.length);
    }
    

    The problem I'm having is that when I try clicking on the emulator, the text field in 'domain' is sometimes selected as expected, sometimes not. When the text is not selected as expected the cursor always appears in the field and the Playbook keyboard slides up by below. What is particularly problematic, that's what often happens, is that the whole scene moves upward on 10px when it is clicked on the ground. If I try to click on the same ground once again, another change to the top of 10px or so, etc..

    So why the text not properly selected and why the scene evolves upwards?

    I realize that more information may be required from me to correctly solve this problem, but if someone has all understand why this may be the case, I would be happy to learn from him.

    Thank you

    David

    I can answer the question of displacement.  This is a bug in BB and supposed to be fixed in version «next» SDK

    The question of the selection, I'll guess has to do with the fileld with focus, selection is not possible.  Try to set the focus outside of maybe the text field?

  • Default properties for the text field of the PDF forms

    How can I set the default properties for the text field?  The creator of forms set of font sizes that are too large.

    Right-click on the field > use current properties as new default.

    It will keep the new settings until the next time that you do this. It is not specific to the document. Do it separately for each field type (text, button, etc.)

    On an existing form, you can select multiple fields. A pro tip, is that you don't have to close the properties to move from the field to the field to the field. Dungeon opens and work faster.

  • query db SQLite to the question of the text fields

    I have a search query that I can send the data to a list, but how do I send data to the text fields?
    for example, I am looking for in a myTable with 4 columns: id, item1, item2, item3, this is the code: I

    private function cSearch (): void {}
    stmt.sqlConnection = this.isDbConnected (sqlConn);
    var sql:String = "SELECT * FROM MaTable WHERE (myTable.item1) LIKE '% ' | '. @item1 | '%' ";
    stmt. [Parameters["@Item1"] = searchInput.text;
    stmt. Text = sql;
    stmt.addEventListener (SQLErrorEvent.ERROR, sqlError);
    stmt.addEventListener (SQLEvent.RESULT, selectResult);
    stmt. Execute();
    }

    If I want to display the data in a list, I'll use this code:

    private void selectResult(res:SQLEvent):void {}
    Table: data var = stmt.getResult () .data;
    cList = new ArrayCollection();
    If {(data)
    for (var d: int = 0; d < = data .length-1; d ++) {}

    cList.addItem ({user.user-id: data [d], item1: data [d] .item1, item2: data [d] .item2t, item3: data [d] .item3});
    }

    } else {}
    trace ("no records available");
    }

    }
    private void displayLData(item:Object):String {}
    Return item.id + ".."  \t"+ item.item1 +"\t"+ item.item2 +"\t"+ item.item3;
    }

    and the list will be:

    < s:List id = "myList" width = "100%" height = "100%" dataProvider = "{cList}" = "displayLData" labelFunction > < / s:list >

    to make it work, the data display

    But what if I want to send the data to a text field 4 diferent?

    I tried, but it does not work

    private void selectResult(event:SQLEvent):void {}
    var searchRes:SQLResult = stmt.getResult ();
    cList = new ArrayCollection (searchRes.data);
    If (searchRes.data! = null) {}
    idSt = searchRes.data.id;
    item1St = searchRes.data.item1;
    item2St = searchRes.data.item2;
    item3St = searchRes.data.item3;
    }
    }

    any help?

    I try this way and it works fine:

    private void selectResult(event:SQLEvent):void {}

    var searchRes:SQLResult = stmt.getResult ();

    cList = new ArrayCollection (searchRes.data);

    If (searchRes.data! = null) {}

    cidSt = cSList.getItemAt (0) user.user;

    item1St = cSList.getItemAt (0) .item1;

    item2St = cSList.getItemAt (0) .item2;

    item3St = cSList.getItemAt (0) .item3;

    }

    }

    the cList, item1St, cidSt, item2St, item3St are declared [bindable]

    and I use labels in order to link the etc. can also be made directly to the label:

    If (searchRes.data! = null) {}

    myLbl1.text = cSList.getItemAt (0) user.user;

    myLbl2.text = cSList.getItemAt (0) .item1;

    myLbl3.text = cSList.getItemAt (0) .item2;

    myLbl4.text = cSList.getItemAt (0) .item3;

    }

    anyawys thanks for you response that helps a lot.

  • Get the value of the drop-down list (selectedIndex) and the text field - does not

    Hi all

    I'm trying to find and change the values selected by the user using a drop-down list and text field. Here's the code.

    ChangeRevDetails();
    function ChangeRevDetails(){
    
    
              var myDialog = app.dialogs.add({name:"Enter copyright information"});
    
    
    //    var monthlist = col1.dropdowns.add('myList', undefined, myList);
    
    
              var col1 = myDialog.dialogColumns.add();
              var col2 = myDialog.dialogColumns.add();
      
        col1.staticTexts.add({staticLabel:"Month:"});
              col1.staticTexts.add({staticLabel:"Year:"});
        col1.staticTexts.add({staticLabel:"Rev. no.:"});
        
        var myList = [ "January", "February",  "March", "April", "March", "April", "May", "June", "July", "August", "Sepetember", "October", "November", "December" ];
    
    
         var myMonth = col2.dropdowns.add({stringList:myList, selectedIndex:0, minWidth:100});//{minWidth:100});
         var myYear = col2.textEditboxes.add({editContents:"2013", minWidth:100});   
         var MyRev = col2.textEditboxes.add({minWidth:100});
    
    
        var RevMonth = (myList [myMonth.selectedIndex]);
        var RevYear = myYear.editContents;
        var RevNumber = MyRev.editContents;
        var RevToReplace1 = RevMonth +", "+ RevYear;
        var RevToReplace2 = RevMonth +", "+ RevYear + " Rev. " + RevNumber;
    
    
        var myResult = myDialog.show();
    
    
            if(myYear.editContents == "") //entry is "" 
            { 
            alert("Please enter some text into the contents field."); 
            ChangeRevDetails(); 
            }
            else if(myResult == true) //user entered datas 
            { 
    
    
                alert (RevMonth);
                alert (RevYear);
                alert (RevNumber);
                alert (RevToReplace1);
                alert (RevToReplace2);
    
    
                app.findGrepPreferences = NothingEnum.nothing;
                app.changeGrepPreferences = NothingEnum.nothing;
    
    
                // grep find/change
                app.findGrepPreferences = app.changeGrepPreferences = null;       
                app.findGrepPreferences.findWhat = "[\\l\\u]+?\\s?\\d{4},?\\s+[\\l\\u]+\\.*\\s+\\d+";
                app.findGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Back page"). paragraphStyles.item("Legal_7/9");
                app.changeGrepPreferences.changeTo = RevToReplace1;
                app.changeGrepPreferences.appliedParagraphStyle = app.activeDocument.paragraphStyleGroups.item("Back page"). paragraphStyles.item("Legal_7/9");
                app.activeDocument.changeGrep();
    
    
                app.findGrepPreferences = NothingEnum.nothing;
                app.changeGrepPreferences = NothingEnum.nothing;
      
        } 
        else //implies user clicked cancel 
        { 
        myDialog.destroy(); 
        }
    
    
    }
    
    

    The problem is, it does not take the value that the user selects in the drop-down list and the text field. It takes the default value as "January" and the year is '2013' as these two values are given as selectedIndex:0 and editContents: "2013". I compared the coding with a few other scripts work as well, but it does not work. I added several alert boxes to check the value we get.

    In addition, search for it and change also does not work. Please help me on this. Thank you.

    Kind regards

    Bachi. D

    Change the order of dialogresults:

    ...

    var myYear = col2.textEditboxes.add ({editContents: "2013", minWidth:100});})
    var MyRev = col2.textEditboxes.add({minWidth:100});)
    Ditto var = myDialog.show ();
        If (myYear.editContents == "") //entry is «»
        {
        Alert ("Please enter a text in the content field.");
        ChangeRevDetails();
        }
        else //user entered if(myResult == true) datas
        {
    var RevMonth = (myList [myMonth.selectedIndex]);
    var RevYear = myYear.editContents;
    var RevNumber = MyRev.editContents;
    "var RevToReplace1 = RevMonth + ', '+ RevYear;

    "var RevToReplace2 = RevMonth + ', '+ RevYear + 'Rev' + RevNumber;

    ...

    did not have a look for the problem of change to find

  • defining the development from stage to the text field

    I am writing a program that asks that a user enters a word in a text field that appears when a button is pressed. Text entry is then compared to an array of words. It works fine, however if the step .ciblent going from the stage to the text field so that there will be a ready blinking cursor in text box o receive the contribution of the users, the input Word will not be considered against the table. The program will not work. the mytextfield.focus works to the point where the cursor is in the field of the tet and receives text etc. but it and says that the word is not in the table. It fails to check it properly. IM 3 days trying to sort and the only way it works is that if the user has to click in the box which is what I don't want. Also is there a way to show the white background textfield without having an error on this subject?

    You are welcome, please mark the thread answered if you have what you need.

    Good luck!

  • problem with the characters of the text field

    Hi all

    I'm missing a few characters, once I insert the text in a dynamic text field. characters are not lacking by saying; they are replaced by empty squares.

    characters such as the euro symbol and accentuated German letter.

    What is weird is that the other German accented letters appear. If only a few selected are missing.

    How Ive set up the FLA:

    (1) I added 4 text fields to the scene to police im using, Arial, one for each font style: normal, italic, bold and bold italic and in all 4 fields ive incorporated all Latin characters (to include the German characters accentuaded and im guessing it is in the punctuation group that contains the euro symbol so that one is also incorporated), not to mention as lowercase, uppercase, numeric, and all the groupd default to include the basic text.

    (2) I have a dynamic text field created with createTextField, and set up the ActionScript code following (2):

    This.createTextField("hello_txt",0,10,10,100,20) ("T_text", 1,0,10,Stage.width-60, 50);

    var myFmt = new TextFormat();

    myFmt.size = 12;

    myFmt.leading = 3;

    myFmt.font = "Arial";

    T_text.html = true;

    T_text. AutoSize = 'left ';

    T_text. Multiline = true;

    T_text.WordWrap = true;

    T_text. Selectable = false;

    T_text.embedFonts = false;

    T_text. TextColor = "0 x 666666 ';

    T_text.htmlText = _global.gallery_1_image_text_1; This holds the im text, called in a database.

    T_text.setNewTextFormat (myFmt);

    now, I'm composing text in a database.

    When calling the text from the browser's address bar, there is no missing characters.

    It's just when I make this appeal of flash and load the text in the dynamic text field, that the characters will be missed.

    Here is a link to a screenshot of the text that is displayed in the text field Dynamics defective flash.

    http://img210.imageshack.us/img210/340/UTF8.PNG

    any ideas? I mean, it seems that the arial font is missing some characters accented! because the code that I have installed loads other accented characters.

    someone has seen this problem before and know how to solve?

    concerning

    stir in your policy.

  • I just upgraded to Firefox 17.0.1 and now I am unable to what it is concluded from the text fields.

    After the upgrade to Firefox 17.0.1 cannot enter text in the toolbar URL, the search bar, or any text boxes/entry forms/fields on Web pages. When you click on the text field, the cursor is positioned properly and flashes but typing does not generate any text.

    OK the solution to this problem (to fear for me) is completely restart the computer.

    Thanks ideato and cor - el to try to help.

  • FlowFieldManager not 'compatible' with the text fields?

    Hi all.

    I'm making an icon to follow the end of a given text. A bit like the phoneLog done with the green phone icon next any number that you enter.

    I tried the substitution of the DrawText, but unfortunately after conditioning to the new line I don't have an X coordinated to begin to draw.

    That's what I would like to:

    +-----------++-----+

    | text 1234 | icon |

    +-----------++-----+

    After entering the text more:

    +--------------------++-----+

    | text 1234567890 | icon |

    +--------------------++-----+

    Unfortunately FlowFieldManager encapsulates the new line icon

    It seems that she's done this before and after each text field. If I have two icons, one after the other, they have a format horizontal, but at the moment where I have to add a textField, it is wrapped in a new line (are complemented by the icons) or icons are pushed to the next line (if the text box before the icons).

    So, how can I add this icon to track the length of the text?

    The problem here is that text fields normally tell their manager encompassing that they want to take the entire width.  FlowFieldManager who will respect and give them the entire width.

    You will need to customize the text field, replace the functions of layout and width and make sure he asks only the size that he actually need.

    If the text cannot be updated, and then you try to use rather than RichTextField LabelField.  LabelField asks only the width he needed.

    Sorry I can't give you any appropriate code because I have never done this.  I did not because from a user interface point of view I don't think it looks good.

    This mechanism can fail when the text field resumed more size on a width - fields are always "rectangular".

  • BlackBerry smartphones increase the size of the text field?

    How can I increase the size of the text field on a 8330?  I can about 5 rows of data.  Thanks in advance

    Sorry, 160 characters, and you cannot change it

  • Tips: APEX 5 r IR by a dynamic action after the text fields complete

    Hello I hope I can get assistance on this matter and thank you in advance for any information.

    I have an APEX 5 screen, that has 4 fields of entry of text and under this one IR that has these 4 parameters in its SQL where clauses.

    Now if I create a button that submits page or redirects to this page my report can be updated with the values of user entered without problem, basic stuff.  If I create the settings section as a dialog box model once again that I can get the update report as this dialogue submits the page as well as the report can refresh according to closed dialog option.

    What I struggle to reach is to allow the user to enter values in the text fields click on a button called 'submit' and there all stages of implementing dynamic action without page reloading.  I want user to P1_A, P1_B, P1_C, P1_D press on "submit" input, dynamic action that links the values entered into the fields, then fire another dynamic action that updates the State when the button is clicked / modified values what works the best.

    I am struggling to get this to work and I even tried to copy these settings and do them as hidden for example bind input P1_A to P1_A_Hidden by a dynamic action and have the report where clause =: P1_A_HIDDEN, but have not managed to get this working.

    It's possible?  I know its easy to simply send the page and make it work, but I want the experience to be quite uniform for the user and act as you never leave the page.

    I saw on the packages of the app in the chart example.  The bubble chart has a list selector (salary) and the table updates dynamically, it seems so that the process can occur, but I need the user to enter text and not use selection lists.

    My apologies if I missed any, but I can give you more if it helps.

    Concerning

    1972903b-5166-494e-8355-08d9d4006e96 wrote:

    Hello I hope I can get assistance on this matter and thank you in advance for any information.

    I have an APEX 5 screen, that has 4 fields of entry of text and under this one IR that has these 4 parameters in its SQL where clauses.

    What I struggle to reach is to allow the user to enter values in the text fields click on a button called 'submit' and there all stages of implementing dynamic action without page reloading.  I want user to P1_A, P1_B, P1_C, P1_D press on "submit" input, dynamic action that links the values entered into the fields, then fire another dynamic action that updates the State when the button is clicked / modified values what works the best.

    The button simply trigger a unique dynamic action of refreshment on the IR region. Session state for page elements must be processed automatically by specifying them in the property Page to submit Items of the IR region.

    Please ensure that you have updated your forum profile with a recognizable username instead of "1972903b-5166-494e-8355-08d9d4006e96": Video tutorial how to change username available

  • How to programmatically launch touch sceen keyboard, when the user clicks on the text field for application?

    Hello

    I create a desktop using the CreateDesktop() API, in this office, I launched a MFC dialog with text field box in this topic.

    I want to get the keyboard touch screen when I touch on the text field of the dialog box.

    I tried to use the following information

    https://msdn.Microsoft.com/en-us/library/Windows/desktop/dd371581%28V=vs.85%29.aspx

    but the key Board launched when I touch the dialogue instead of text field.

    Please give me the solution?

    Pramod Hello,

    Thanks for posting your question on the Microsoft community.

    This question fits better to the developers on MSDN forums.

    I would recommend posting your question on the MSDN forums.

    MSDN forum
    https://social.msdn.Microsoft.com/forums/en-us/home?category=windowsdesktopdev

    Thank you

  • Align the text field and a button.

    Hi all

    I use Oracle APEX 5.0.1.

    I tried to create a search page that contain a text field and a button.

    But I can't align the text field and button, so they can have the same top position.

    Could someone please help me solve this problem?

    APEX-ARE-Search.jpg

    Thank you and best regards,

    Troy.

    Hello.

    Have you tried to add a css attribute to the button? like: style = "top: 4px;

    Concerning

Maybe you are looking for