Changing the cursor position in an input text field and Removing leading numeric zeros

Flash8 - AS2
It's good to be back after all these years and thanks for the faithfull folks like kglad, Ned Murphy, Rothrock and all the others who give so much of themselves to make this forum a success!
My Problem:
I have an input text field that is named in the properties box as 'numberOfKids'.
When the program is executed, and a delete or backspace is pressed the input textfield goes blank
and any calculations that use 'numberOfKids' shows NaN.
I have trapped the NaN and undefined so that a numeric 0 shows up instead of a blank.
There are two problems:
First problem:
  The cursor is to the left of the zero, so the first number inputted by the user is 10x larger than what they want.  0 becomes 10.
Question:  How do I get the cursor to move to the right of the 0?
Second Problem: 
  When I manually move the cursor to the right of the 0 and input a number, say 4, it shows up as 04.
Question 2:  How do I delete the leading numeric zero in the input textfield?
Thanks for the help.
Here's the code I am using:
calculateChildWeight = function () {
if (isNaN(numberOfKids)) {
  numberOfKids = 0;
if ((numberOfKids) == undefined) {
  numberOfKids = 0;
if (numberOfKids>=0 && numberOfKids<=137) {
  numberOfKids = numberOfKids;
} else {
  numberOfKids = 0;
if (isNaN(adjustedChildWeight)) {
  adjustedChildWeight = 0;
if ((adjustedChildWeight)=undefined) {
  adjustedChildWeight = 0;
adjustedChildWeight = Number(numberOfKids*(-100));
//numberOfKids.setSelection(numberOfKids.length, numberOfKids.length);
//if (numberOfKids.length=2 && numberOfKids<10) {
  // remove the first character or leading zero
//  numberOfKids = numberOfKids;

Thanks Rothrock for being so  patient.
I'm lost!
I go back to a brand new flash file to try and implement the textfields as a stand alone test document.  I have lost the concept I think.
I created on the stage of a blank .fla file  4 text fields, 2 input and 2 dynamic.  I gave them an instance name in the properties box.  I use this instance name.text to find the value of the field.  I use the parseInt to put that value into a numeric variable for calculation.  The results are put to the appropriate textfield.
All seems to work except one of my input text fields.   I use the value of this field  to calculate:
revisedValue = parseInt(numberOfKids.text);
revisedValue = revisedValue*(-100);
The problem now is that if the numberic '2' is inputted into numberOfKids, numberOfKids.text shows up as 200 and a trace shows up as '2NaN'.
Flash is logical and consistant, I must conform to it but I'm in the dark.
(( Concerning the forum:  If I click on helpful, which your posts have been in directing me, does that blank out the possibility of selecting the correct answer in the future???))

Similar Messages

  • Is there a way to get the cursor position index of html text field

    I'm trying to work on a text pad like MC with "insert text at
    position X" and "find and replace" can anyone tell me how to find
    the cursor index of an html text field. Selection.getBeginIndex() ,
    Selection.getEndIndex(), Selection.getCaretIndex() as far as I know
    these methods only work with text and not htmltext.
    What I'm trying to do is assign different parts of the string
    to variables so that I can combine them to reconstitute my html
    string.

    enfantterrible:
    If I understand correctly, you want the corresponding
    position in the
    htmlText propery of the caret index (which as you point out
    is only the
    position in the plain text version of the textfield content).
    Below is how I would do it. Maybe there's an easier or more
    efficient
    way (using XML objects etc), but I don't know it. You could
    conduct all
    your string searches in the plain text and then convert the
    result to
    the html positions. I didn't build this to accept negative
    parameters
    for the pos parameter (e.g. from end of string backwards) but
    the
    function could be adapted to do this too if necessary. The
    test data is
    not proper html from a text field, but it doesn't really
    matter what it
    is so long as its formatted correctly. It just separates the
    tags from
    the content to enable apples with apples comparison.
    //some test data
    var testStringXML = "<format>Hel<b>lo i can't
    t<i>ell you h</i>ow hap</b>py I
    am.</format>";
    var undecoratedString = "Hello i can't tell you how happy I
    am.";
    //the conversion function
    function findDecoratedPosition(pos:Number, xmlString:String,
    test:Boolean):Number {
    //anything between '<' and '>' should be excluded from
    plain text search.
    //create an array of array elements (n=2) consisting of tag
    then plain text
    //requires correctly formatted xml/html
    var tempArr:Array = xmlString.split("<");
    for (var aa = 0; aa<tempArr.length; aa++) {
    tempArr[aa] = tempArr[aa].split(">");
    //remove the first and last elements of the new array (these
    are empty)
    tempArr.pop();
    tempArr.shift();
    //find the corresponding plaintext location and calculate
    the "decorated" position
    var retPos:Number = 0;
    var posCount:Number = 0;
    for (var aa = 0; aa<tempArr.length; aa++) {
    retPos += tempArr[aa][0].length+2+tempArr[aa][1].length;
    //+2 allows for missing < and >
    posCount += tempArr[aa][1].length;
    if (posCount>pos) {
    return (retPos+(pos-posCount));
    //out of range
    return -1;
    //test code:
    for (var aa = 0; aa<undecoratedString.length; aa++) {
    var altPos = findDecoratedPosition(aa, testStringXML);
    trace(undecoratedString.charAt(aa)+" in position "+aa+"
    plainText equates to position "+altPos+" in the decorated version
    ["+testStringXML.charAt(altPos)+"]");
    }

  • ADF Mobile: How to change the font size of an Input Text field in .amx view

    Is there a way to change the font size of the input data (not the label) in a text field? Changing the font size in the Style Font/Text settings doesn't seem to do anything for the label or the value in the input text field. Is this a bug or is there a way to get this to work?

    Hi Anna,
    depending on the UI element there are a range of ways. (and I'm sure people will post plenty of answers to tell you how).
    However, if generically the fonts in you portal/wd applications are too small, you should consider changing your theme so as to have larger texts. Otherwise you will either need to customise all your applications, or you will get quite a lot of inconsistency of presentation between your various WDA applications.
    Do a search on "themes for Web Dynpro ABAP" and you'll find loads of resources.
    Hope this helps,
    Cheers,
    Chris

  • How do I change the size of a Spry Input Text field box?

    I created an email reply box, and then I created a reply message box. How do I change the size of each box independantly of each other? All I have is one set of Spry CSS rules!
    Oh, and the Working with the Validation Text Rule widget file in the Help Resource Center only covers changing the background color - Ugh!

    If I understand your question, you want to change the size of the input field that has spry validation?
    Spry has nothing to do with it, add a size to the field
    <input name="textfield1" type="text" id="textfield1" size="45" />
    <input name="textfield2" type="text" id="textfield2" size="25" />
    Gary

  • Changing the cursor position

    Is it possible to change the cursor position automatically when changing the language?
    For example: when changing from English to Hebrew the cursor will move from the right end to the left?
    Thanks,
    Amnon

    I don't think this is possible in general, although some individual apps might do it.  Normally you use a direction control from an app menu or at the system level.
    http://support.apple.com/kb/PH14203

  • Query regarding changing the background color of an input text

    Hi,
    I want to change the background color of an input text component.When I tried with the back-ground color inline style, it changed the color of the label instead of changing the background color.Is there any way I could do it?
    Thanks in advance

    Hi,
    use the contentStyle property (or skinning af|inputText::content if you want to change this in one place for all input text fields)
    Frank

  • How to impl. Enter key (when fill some input text field and then submit)

    I have some input field for login user in application and then when user submit on enter I want to login process start.
    Which is my solution for this?
    Now, user can login process start with click on Log in button.
    Thx.

    See complete explanation:
    http://blogs.oracle.com/Didier/ButtonToSubmitForm
    and download sample 2:
    http://blogs.oracle.com/Didier/Samples

  • How to control the cursor position on a text item..

    Hello,
    How can we control the cursor position programmatically on a text item.
    i.e. how do we move the cursor to home or end of the text item.
    TIA,
    Hiten

    If you have an access to metalink.oracle.com, take a look at notes:
    Note 61656.1 (V45) HIGHLIGHTING A REGION OF TEXT
    Note 131028.1 Default Highlighting in Forms (Client Server)
    and threads from metalink forum:
    531481.996 "Select_All not working in 6.0.8.25.2", 153092.995 "Text item cursor position"

  • Value of input text field not changed!

    hi,
    i have a select menu. when i change the value of the select menu, i have the event method and in the event method i change an value of a other input text field, but in the html page, the input text doesn't change his value.
    i bind the input text field to the value field in class with the folowing command.
    <h:inputText binding="#{backing_main_test:testInputField}" value="#{backing_main_test.testValue}"/>
    please help me.
    thanks, christoph

    <h:inputText binding="#{backing_main_test: <--- was that colon intentional?

  • How Can i send the data entered in Input text fields to e-mail?

    Iam Jennifer, Iam having a doubt in Flash, I hope that you
    are going to solve my problem, Iam taking 3 Static text fields as
    Name, Age and Country and besides each and every static text fields
    i have taken 3 input text fields with different instance names,
    when i enter my Name, Age and Country details in the input text
    fields and after entering those details if user clicks the submit
    button the data should be send to some mail address, is it possible
    Im not so good at action script, but i hope that any one can
    help me...
    Iam attaching the action script code also, please find the
    attachment below, the actions are given to button.
    Attach Code
    Btn.onPress = function ()
    mail_lv = new LoadVars();
    mail_lv.dummy1 = "";
    mail_lv.subject = "Details";
    mail_lv.message = "hi";
    mail_lv.username = "name_txt".text;
    mail_lv.age = "age_txt".text;
    mail_lv.country = "country_txt".text;
    mail_lv.onLoad = function ()
    trace("Sent successfully...");
    trace("mail_lv.subject = " + mail_lv.subject);
    trace("mail_lv.message = " + mail_lv.message);
    mail_lv.send("mailto:[email protected]", "_blank");

    The names of your variables, "name_txt", for instance, should
    NOT have quotes around them. Use:
    mail_lv.username = name_txt.text;
    mail_lv.age = age_txt.text;
    mail_lv.country = country_txt.text;

  • Regarding Input text fields

    This is about fill in the blanks in flash 8 as2. In this i used input  text fields and three buttons.In first frame i used multiple input text  fields and a submit button. After filling all the blanks we click on  submit button then in the second frame we will show the result like if  the blank is correct it should change the color to green and if it is  wrong it should change to red.and in the frame i have check button when  we click on it will display all the answers. And when we click on  analyse button we have to display the answer which the user types and  the correct answers.
    And my problem is when we click on submit there is no difference in the blanks color all are in black only and i have assigned red to the wrong answer and green to the correct answer.
    and script on submit button is
    on (release) {
        gotoAndStop("Bl1");
        if ((_root.Bl.txt1 == "abc1") && (_root.Bl.txt2 == "abc2") && (_root.Bl.txt3 == "abc3") && (_root.Bl.txt4 == "abc4")) {
            _root.Bl.txt1.textColor = 0x006600;
            _root.Bl.txt2.textColor = 0x006600;
            _root.Bl.txt3.textColor = 0x006600;
            _root.Bl.txt4.textColor = 0x006600;
        } else {
            _root.Bl.txt1.textColor = 0xFF0000;
            _root.Bl.txt2.textColor = 0xFF0000;
            _root.Bl.txt3.textColor = 0xFF0000;
            _root.Bl.txt4.textColor = 0xFF0000;
    where "Bl" is the movie clip name and "txt1","txt2","txt3","txt4" are the var names for input text fields
    Please help........

    You are concatenating the conditions it will only work if all are true or  all are false
    on (release)
        gotoAndStop("Bl1");
        if (_root.Bl.txt1 == "abc1")
            _root.Bl.txt1.textColor = 0x006600;
        else
            _root.Bl.txt1.textColor = 0xFF0000;
        if (_root.Bl.txt2 == "abc2")
            _root.Bl.txt2.textColor = 0x006600;
        else
            _root.Bl.txt2.textColor = 0xFF0000;
        if (_root.Bl.txt3 == "abc3")
            _root.Bl.txt3.textColor = 0x006600;
        else
            _root.Bl.txt3.textColor = 0xFF0000;
        if (_root.Bl.txt4 == "abc4")
            _root.Bl.txt4.textColor = 0x006600;
        else
            _root.Bl.txt4.textColor = 0xFF0000;
    You can also run a for loop for optimizing the code further.
    www.darshanrane.com

  • How to get the cursor position in the text edit box?

    Hi, all.
    I want to get the cursor position in the text edit box
    to insert some data.
    But I don't know how to get.
    Can someone give me some advice?
    BestRegard.
    Miya.

    Hi Miya,
    Write your own textSelectionSuite for this.
    and use ITextTarget->GetRange() function.
    Thanks and Regards,
    Yopangjo.

  • Setting the cursor on a particular input field in module pool

    Hi,
    I am working on an abap module program, the requirement is the cursor should be placed on a particular field at run time.
    In detail:  Table contains zserialno primary key field, zemailid of char type.
    Screen design: 1st text input field is zserialno
                             2nd field zemailid is splitted into 3 input text fields.
    For 2nd field zemailid 1st input field allows user to enter his/her email name, 2nd input field is an drop down which contains domain names and 3rd field is an empty field which is to be triggered on user action.
    example: zemailid- 1st input field  XYZ 2nd input field conatains @gm../@yah....and others. If user selects on others value in drop down of 2nd input field, the cursor should point the 3rd input field which allows the  user to enter his/her other domain.
    I used
    SET CURSOR FIELD <3rd inpu field namet>.
    , but the cursor pointing the key field of the table zserialno even the input field of zserialno was provided with a value.
    Any idea on this is appreciated.
    Edited by: Sona_abaper on May 7, 2011 5:34 PM

    Hi Sona,
    F1:
    Effect:
    During PBO processing, this statement sets the cursor in the screen layout of the current screen. The cursor can be positioned by entering a screen element after FIELD or by entering a specific position using col and lin. Outside of PBO processing, the cursor is positioned in the next list displayed on the screen.
    If the SET CURSOR statement is not specified, depending on the definition of the screen, the cursor is set according to the following hierarchy:
        On the cursor position determined statically in the screen properties,
        On the first input field of the screen,
        On the first screen element of the screen,
        On the command field in the systemtoolbar.
    The latter also applies if the command field in the system toolbar is not displayed.
    I'm convinced your code works as designed.
    Let us know your PBO module and code.
    Regards,
    Clemens

  • Locating the cursor position

    Is it possible to locate the cursor position in a text item? in other words can I find the number of characters to the left of the cursor in a text item?
    I really appreciate any kind of input on this.
    null

    I have to insert user selected variables that show up in a LOV into the text item at the cursor position.
    A sloppy workaround for this problem is asking the user to put in a pre defined symbol where ever he/she wants to insert the variables and then replace the variable with the value selected from the LOV using the REPLACE function. There is always a chance of error here!
    Instead if there is a way to know the cursor position, like the no. of characters to the left of the cursor or the cursor co-ordinates.............

  • How to control the cursor position in the Table control in Module pool

    Hi,
    Can any body tell me how to change the cursor positon from last field of the first record to the
    first field of the second record , when user presses enter in the last field in the module pool
    programming.
    Thanks

    Hi,
    Please avoid posting duplicate posts.
    Re: how to get the cursor position from screen in module pool program
    Nag

Maybe you are looking for

  • HTMLDB 1.6 / doSubmit issue

    My original problem: I have numerous instances where I have a form region at the top of the page, and then a report at the bottom of the page. For instance, the top of the page might be header information, and the bottom of the page detail informatio

  • How can we migrate bill presentment templates from DEV to PROD?

    Hi, E-business suite 11.5.10.2 Once we have designed a bill presentment template in the development environment, how can we migrate it in other environments? (TEST, PROD). Thanks.

  • Unable to select multiple images for upload

    I have Windows 7 Pro and FF 9.0 I have an online store and am always uploading product photos for items I have listed. I recently switched from XP Pro to Windows 7 Pro. I had no issues with XP. However, now that I have Windows 7 Pro I am unable to se

  • How to Create and adjust masks with SDI output or Dual monitor output activated?

    Hi all Speedgrade community. For me one of the biggest problems I constantly encounter is managing masks within speed grade. The tools are great, but if your using and external reference monitor for grading there is no way you can manage masks and se

  • About XI fundamentals

    Hi Experts, I am new to XI, i have one doubt on connectivity of existing integration. 1. I read somewhere that XI connects to existing integration solutions     through JMS and SOAP messaging, is it so.....? 2. What is JMS and SOAP messages, what is