This test  to display text field in a conditional statement

Still a newbie! I want to test the display for my calc app so that you can't add zeros to the display's default zero i.e. if the display is "0" and I keep pressing the "0" key , it won't get appended to the first zero.
if(nonum == "0") doesn't seem to work
public boolean processKey (int keyCode) {
String newnum = curnum;
String nonum = display.getText();
if (keyCode >= 0 && keyCode <= 9){
if(nonum == "0"){
newnum = Integer.toString(keyCode);
System.out.println("display reads "+nonum);
}else{
newnum += Integer.toString(keyCode);
else if (keyCode == POINT)
newnum += ".";
try {
Double.parseDouble(newnum);
curnum = newnum;
System.out.println("newnum = " + newnum);
System.out.println("curnum = " + curnum);
return true; }
catch (NumberFormatException nfx) {
return false; }

Since you are storing the number as an 'int' and then converting that int to a String for display, then you shouldn't expect 0's to be added on if the number is currently 0:
1) curnum = 0
2) 0 key is pressed
3) curnum = curnum * 10 + 0 = 0 * 10 + 0 = 0
A real calculator wouldn't keep appending 0's... at least, not a simple calculator comparable to the one you are writing. If you want to append 0's, try this:
- Keep a count of the number of 0's pressed.
- If curnum is changed to 0 (by pressing clear, for example, or turning on the calculator), reset the zero count to 1.
- Each time the '0' key is pressed, if curnum is 0, then increment the '0' count.
- When you update your display, use the following logic: if curnum is 0, then display the number of 0's specified in the zero count, otherwise just display the value of curnum.
Jason

Similar Messages

  • Text box not empty conditional statement

    I've been asked to develop a survey and, in several places, a
    score is given for the completion of text box. However, if there is
    no text in the box, then a score of zero should be given.
    I thought the best way to do this would be to use a hidden
    field with a conditional statement saying "if text box is not empty
    then score=4, else score=0.
    However, firstly I'm not sure how to write this and secondly,
    how do you check if a text box is empty?
    I think it really calls for some human input but the client
    is quite sure this is how he wants it.
    The scores are all going to be inserted into a mysql database
    and sorted out there, so there may be some fudge available there
    but if php could do something nice in the code, that would be
    preferable.
    Thanks in advance.
    Andrew

    Drewbles wrote:
    > However, firstly I'm not sure how to write this and
    secondly, how do you check
    > if a text box is empty?
    Believe it or not, with the PHP function called empty();
    http://docs.php.net/manual/en/function.empty.php
    if (empty($_POST['fieldName'])) {
    // give a score of 0
    } else {
    // give a positive score
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Quick qn on displaying text fields from region.

    My doubt is that i have a page where
    there are 2 Regions..top and bottom Regions
    we can enter a person's details on the bottom region and hit submit..then that person get stored in the database and visible on the top region
    i have a situation where i need to grab these people from the top region and display in side email message
    my text field in the bottom region is not constant..so i am not able to capture them..
    Its like this:
    TOP REGION:
    tommy lee Male address 1
    kanan jones Male address 1
    babu lee Male address 1
    Note: Sometimes there may be only one person..sometimes more than 1 like 2 or 3
    Bottom Region:
    text fields to enter (we can enter for only one at a time)
    ..I am able to grab it from the table in the DBase..But how can i get it to the email message..
    Appreciate your help
    thanks
    kp

    You can select the entire field and use the cold fusion left
    function. However, it would be more efficient to simply select
    select the 1st 20 characters in your query. How you do this depends
    on the db you are using.

  • To display text field with more than 1000 length in ALV

    Hi Friends,
           I need to display material long text field which is more than 1000 length in ALV or Object oriented ALV.
    Please help me to resolve the issue.
    Regards,
    Jaya.

    Hi,
    U mean to say in a single cell of ALV ??
    It is not possible in ALV .. As per OSS note 857823
    Below is the reason for same.. I think you should to split in number of columns.
    Summary
    Symptom
    Entries in cells of the type CHAR or string are truncated after 128 characters in the SAP GUI.
    Other terms
    ALV Grid Control (cl_gui_alv_grid), function module (Full-screen)
    Grid (Reuse_alv_grid_display, SAPLSLVC_FULLSCREEN), SAPGUI, back end, front end
    Reason and Prerequisites
    The data table that is sent to the front end only allows character values with the length 128.
    Solution
    This is the standard system behavior and cannot be changed.

  • Display text fields based on value

    I have a form that has 7 text fields that are to be filled out. I have an ajax process that auto-populates those 7 fields with values based off of the return value of a pop-up dynamic LOV. Is there any way that I can hide the last 5 fields based on a certain value of one of the text fields?
    For example, my fields are:
    P1_Badge (LOV query)
    P1_First_Name
    P1_Last_Name
    P1_Title
    P1_Phone
    P1_Room_No
    P1_Email
    P1_Fax
    The LOV returns a Badge number and populates the rest of the values. But if the Last_Name = 'Smith' then I only want to display Badge, First_Name, and Last_Name and I want to hide the rest of the fields or make them disabled for editing.
    Is this possible without any kind of page submit?
    Thanks,
    Dirk

    Hello,
    Take a look at this page http://apex.oracle.com/pls/otn/f?p=11933:39 it has examples of what you want.
    Regards,
    Carl
    blog : http://carlback.blogspot.com/
    apex examples : http://apex.oracle.com/pls/otn/f?p=11933:5

  • Display text fields from check box?

    Hi
    Is there a way to display hidden text fields in a form
    whenever the check
    box is clicked?
    For example I have an option which asks how may we be of
    service to you?
    One option is 'estimates on conveyancing' , once this is
    clicked I need to
    display further text fields (estate agent, name of property,
    price of
    property etc)
    Thanks for any help

    Nope.
    First, I had trouble figuring how to apply the Form Calc to the Button, as opposed to the Button List.
    I actually had to edit the first line in the Script Editor, which seems pretty lame.
    That is to say, I just don't see how to get to the radio button, not the Object named RadioButtonList
    BUT, I can't UNCHECK the field once it's been checked. That is, if I click "on" the Radio Button, it won't revert to unchecked if I try to click it "off".
    In other words, if the person unchecks the Radio button due to some error, I need it to click off and the TextFiled to go back to being hidden.
    Like I said, this can't be that hard, or maybe I'm just missing what you're trying to explain. Any other ideas?
    Steve

  • Display Text Field data in SmartView

    We have a planning form that accepts input of a text field for a "project name". When I query via SmartView (ad-hoc) it shows a numeric value instead of the field (project name). We have tried creating FR reports to show this information but our reports keep shutting down the services because of performance issues. Does anyone know in which Oracle repository tables does this information get stored (i.e., the Numeric Id value that matches the String value)?

    Hi,
    We have faced exactly the same FR problem number of times in different projects. You haven't mentioned your version number. If it's 9.3 series, there is no solution to your Financial Reporting problem unfortunately. For 11.1.1.1+ though there is one solution. Assuming that you are using Planning details connection, click on top left corner of the grid, on the right hand side, where the properties of grid is listed, you must see a little box about suppression (or hiding) missing planning blocks. Enable this and try again. this will keep only already populated fields in your report, which I'm sure is fine.
    As for your smartview problem, as Rinku suggested essbase connection doesn't bring the text files as these are separately stored in repository. However, you have limited ad-hoc capabilities in System 11 Planning. Look for the key word "smart slice" in the admin guide.
    Cheers,
    Alp

  • Problem In Displaying Smartform Text Field In Qual & Prd Server

    Hi All,
    I am working on a smartform in which i am checking the field which is displaying fine in quality server but when it is transported to PRD server it is displaying text field  in the smartform having ms word document which is giving me problem in displaying in the PRD Server.
    Please provide me guideline for it..

    Hi Sarvan,
    Post the code in code format.Check on the right side for example.
    Sy-subrc  = 0
    Regards,
    Madhu.

  • How to autopopulate a text field with unique data from multiple data sets

    Hi,
    I'm a laboratory manager in charge of a hospital project which will be using pdf forms to send and receive data from our end users across the city. I need help with the last part of our pdf form, specifically with a js that will do a bit of text-field autopopulation magic. This, unfortunately, is a beyond what I have taught myself about pdf js functionality.a
    The problem:
    I need to provide my end users with a text field containing a set of data [A, B, C, D, E, F ...] and the total items in this set [tot#]. The end user needs this information as part of the implementation of this particular laboratory machine.
    The particulars
    When the end user asks for an experiment to be run, we must specify some pieces of data to help them interpret the results. These are constructed as panels which contain discrete data elements.
    For example - One experiment may use two panels, Panel#1 and Panel #2. Panel #1 includes the items A, B, D, E, Panel #2 includes the items A, B, C, F, G.
    Thus, the panels may share some of the same items, but, I only want the unique members to be displayed in the text field. If I make a drop down box or checkboxes with the panels, I want to  be able to select the panels that we ran and (in this example) have the text field display only the unique items among all the panels that were used:
    textfield outpute = A, B, C, D, E, F, G - 7 total.
    Any assistance from the pdf community would be very much appreciated.
    Thanks!

    Thanks for that help.
    I should have made it more apparent that I'm very new to scripting and I'm
    not a programmer by trade. I have a few questions before modifying the code
    you kindly provided.
    1) Where should I embed this script? Within the 'selection change' area of
    my listbox?
    2) Can I replace the term 'arr' with the names of the various items in my
    listbox or should I put 'arr#' as the output value for each term?
    3) Will this script find and display the unique values when a user selects
    multiple items in my listbox?
    4) How does the script know where to output the unique members of the
    combined set?
    I appreciate your patience with me.
    ck

  • Button Setting Variable - Text Field Not Updating

    Hi,
    I am working with Acrobat 9 Pro on Windows.
    I am unable to make the following work: When the user clicks a Button, a Text Field appears with the text associated with the Button clicked. I have tried accomplishing this with a variable declared in the Document JavaScripts, buttons setting the value of the variable, and a Text Field containing a Custom Calculation Script that returns the text associated with the value of the variable.
    Everything works - except the Text Field doesn't return the text associated with the value of the variable. I have an app.alert (for now) in the button scripts so I can see if the variable has the correct value - and it does - but when the Text Field appears - the text never changes.
    What I have observed: if I go back into the Custom Calculation Script of the Text Field and do nothing, go back out, go to Preview, and click on a Button, the text updates to the previous variable value (not the Button variable value I just clicked).
    So - I think - the Custom Calculation Script isn't seeing the new variable "on the fly". Even though the app.alerts are. I don't think this is a Field Calculation Order problem. But maybe it is. And this is where my brain power ends. Any suggestions would be greatly appreciated. Thank you.
    I have this in the Document JavaScripts:
    var ITrig = 1;
    I have three Buttons (want to have more) that will set the ITrig variable.
    Here is what I have in one Button:
    var Inpopup = this.getField("PartASectionIIInstructions")
    ITrig = 2;
    app.alert(ITrig);
    if (Inpopup.display == display.hidden) {
    Inpopup.display = display.visible
    Inpopup.setFocus();
    } else {
    Inpopup.display = display.hidden;
    I have this in the PartASectionIIInstructions Text Field in the Custom Calculation Script:
    if (ITrig == 2) {
    event.value = "#2";
    else if (ITrig == 3) {
    event.value = "#3";
    else if (ITrig == 4) {
    event.value = "#4";

    Thank you. I had tried something like that earlier - without success. That is why I went to the calculation script. So - I went back to the "Acrobat Forms - JavaScript Object Specification" looking for an answer. It finally sunk in I was guilty of this:
    var Inpopup = this.getField("PartASectionIIInstructions").value
    Inpopup = "#3"
    When I should have been doing this:
    var Inpopup = this.getField("PartASectionIIInstructions")
    Inpopup.value = "#3"

  • Can't select CMYK text colour for text fields in Acrobat Pro forms?

    I have designed a business card template in Indesign, and now want to use Acrobat Pro to add in text fields so that a client can edit the contact details on the cards in future.
    I need to select a specific text colour for the fields, so that it matches the rest of the design. The cards will obviously need to be printed and the document has been set up in CMYK, but when I enter the CMYK colour breakdown in the Properties > Text Colour panel, it won't apply the colour to that field. The text either stays at the default black, or reverts to RGB - which isn't suitable for printing and doesn't match the colour I need.
    Can anybody PLEASE shed some light on this? Other similar posts have either not been answered or people have suggested JavaScript..? I have no idea what I'm supposed to do with a JS code..? Surely there's an easier explanation?
    Thanks in advance.

    This is for a text field that you create in Acrobat, whether the form is used offline or online. The script is a custom Format script, which you can place by bringing up the Properties dialog for the field, select the Format tab, set a format category of Custom, and you should see where you can enter the script. Change the string "Instructional text goes here" to the text you want to display when the field is blank.

  • Weird wrapping in a text field

    I am using Dreamweaver 8. Here is the code: </p>
    <br />
    </span>
    <textarea name="Educdis" cols="120" wrap="physical"
    id="Educdis"></textarea>
    <span class="style5"> <br />
    <br />
    How do I fix this? In the formication file after 12 lines of
    data, exclamation marks are inserted with the last character
    between them as follows:
    This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. !
    Th!
    is a test of the text field. This a test of the text field.
    This a test of the text field. This a test of the text field. This
    a test of the text field. This a test of the text field. This a
    test of the text field. This a test of the text field. This a test
    of the text field. This a test of the text field. This a test of
    the text field. This a test of the text field. This a test of the
    text field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. !
    T!
    his a test of the text field. This a test of the text field.
    This a test of the text field. This a test of the text field. This
    a test of the text field. This a test of the text field. This a
    test of the text field. This a test of the text field. This a test
    of the text field. This a test of the text field. This a test of
    the text field. This a test of the text field. This a test of the
    text field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field. This a test of the text field. This a test of the text
    field.!

    I just tried that form element on a page and I can't get it
    at all to wrap like that. Does it only occur when the wrap is a
    physical one?

  • 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

  • PHP/MySQL: 'Add New' text field from menu in form

    I am creating an events posting website. I'm having a hard time finding the right words to describe this, but: I'd like the user to select a venue from the drop menu, but then if it isn't there, to select 'add new' from the dynamic menu, and have a new text field activate where they can enter in the new venue name. My database is currently set up so the event table links to the venue table through a venueID. Is there a way to insert the name from the new text field into the venue table, and have the rest of the form still submit to the event table? Sorry this is so wordy, but I'd appreciate any help. Thank you.

    You cannot add a new value to a related table at the same time as inserting a record. So, to do this, you would need to use both JavaScript to add the new text field, and PHP conditional logic to handle the update to both tables. It's certainly doable, but not with the Dreamweaver server behaviors. You would need to do a lot of hand-coding yourself.
    The way that I approached a similar problem in my "Essential Guide to Dreamweaver CS4" was to permit NULL values in the column that holds the foreign key, and insert nothing into that field if the value hadn't already been registered in the related table. I created a static value in the dynamic menu for "Not registered".
    After inserting the new record with "not registered", the user then needs to enter the new value in the related table.
    Once that has been done, display a page that lists all records. In the SQL, I use a LEFT JOIN to ensure that "not registered" items come up as well. You can then edit the item to add the value from the dynamic menu.
    It's not the most elegant way to do it, but it works if you don't have the skill or time to hand-code all the logic yourself.

  • Can't hide text field label..only text field

    I'm trying to display text field boxes on a form to fill out when a box is checked.  I'm able to do this for the actual text field, but can't figure out how to hide then show the associated text field label.  Can you tell me what I'm doing wrong?
    Thanks!
    var nHide =
    event.target.isBoxChecked (0) ? display.visible:display,hidden;
    this.getField ("Name").display = nHide; this.getField

    First of all, you're using Acrobat JavaScript in an XFA form, which doesn't work.
    LiveCycle Designer has its own interpretation of JavaScript, which is different to Acrobat.
    There is also a second scripting language called FormCalc available.
    Its syntax is much easier to learn and is matches perfectly to manipulate XFA forms.
    Check the help (F1 button) in Designer to get the Designers scripting guide.

Maybe you are looking for

  • How to cancel BT broadband

    After 3 weeks of having no broadband and BT refusing to believe it's their equipment its now time to cancel. I've had a look at my account online but can't see how to cancel. I've had it for many years so I'm guessing there won't be a cancellation fe

  • Pda graph redraws every time when cursor is moved

    Hi, I use PDA Module 8.2 and Windows Mobile 5 OS on PDA. I have a problem that every time I move cursor on graph control plot is being redrawn, so it realy annoying when you have 5000 or more points and you have to wait a second while plot is being r

  • Safari keeps crashing on my boyfriends Mac?

    My boyfriends Mac has been crashing lately. Not the whole computer, just Safari. Whenever we run it, about 30min-1hr in Safari will crash and we'll get this little message: http://i1166.photobucket.com/albums/q601… His Mac has a 3.2GHz Intel Core i3

  • Re Photoshop via the Cloud

    As I understand it, if I subscribe to Photoshop via the cloud for around $20 per month and use it for say two or whatever years then have a cash flow problem and stop paying for a period of time, Adobe not only stops sending updates but they disable

  • Problems receiving mail from exchange after upgrading to Mavericks

    After upgrading to Mavericks I am having issues receiving e-mail. Activity doctor says I am connected to Exchange server but Mail.app won't donwload e-mail. I have heard this is an issue on OS X Mavericks. Any idea on how to solve this?