How can I add 2 variables that are entered via input text/number type

So I have created 2 text fields via composition ready
$("<input type='text' value='' name='input1' id='input1' size='5'>").appendTo("#Stage");
sym.$("#input1").css({"position":"absolute","top":"70px", "left":"52px"});
$("<input type='text' value='' name='input2' id='input2' size='5'>").appendTo("#Stage");
sym.$("#input2").css({"position":"absolute","top":"90px", "left":"52px"});
input1 AND input2.
The user then puts a number in each field.
I have a 3rd field created to hold the answer. I also made a text field with the name "scorefield" to see if that would work, either will do.
Then on a button on the stage, the user clicks on it to add those first two numbers together and have the sum appear in the 3rd field or the text field that has the symbol name "scorefield".
However I can not seem to be able to add the 2 values of the text fields. On the submit button I have:
var number1 = $("#input1").val();
var number2 = $("#input2").val();
var additionresult = number1 + number2;
sym.$('scorefield').html(additionresult);
answer1.value = additionresult;
The problem is that it is NOT adding number1 and number2 together!
If I substitute + for - or / or * it works using those symbols, but if I try to use the plus sign and add the two, it does not work and instead physically adds the numbers next to eachtoher.
So If I were to put a 5 in field one, and a 2 in field 2, the result comes out to be 52...instead of adding the two values, it places them next to eachother.
I know those ARE numeric values because any other mathamatical sign works. I can multiplay, subtract and divide those two numbers. I can even check to se if its higher or lower of a value using > or <.
But when I use the + sign, it breaks.
Is there some other sign I must use to add two values?

Sorry I forgot to change the string to a integer earlier. Here it is corrected.
file here: https://app.box.com/s/mulkhd1rlyyafovqc3od
var input1 = sym.$("input1")
input1.html("number1: ");
userInput1 = $('<input />').attr({'type':'text', 'value':'', 'id':'input1'});
userInput1 .css ('font-size', 28);
userInput1 .css ('width', 50);
userInput1 .appendTo(input1);
var input2 = sym.$("input2")
input2.html("number2: ");
userInput2 = $('<input />').attr({'type':'text', 'value':'', 'id':'input2'});
userInput2 .css ('font-size', 28);
userInput2 .css ('width', 50);
userInput2 .appendTo(input2);
sym.$('btn').click(function(){
var number1= userInput1.attr('value');
var number2= userInput2.attr('value');
var Numone = parseFloat(number1);
var Numtwo = parseFloat(number2);
var answer = Numone + Numtwo;
sym.$('result').html(answer);

Similar Messages

  • How can I add a variable that will always be relevant to a decision report?

    I would like to add assessment date and assessment notes to a decision report, such that these two variables are always displayed (always relevant), regardless of whether the overall conclusion is true or false. What would be the best way to do this?
    Thanks,

    Is there a reason why the assessment date and notes are part of the eligibility rule? Looks like the assessment date and notes are just two bits of information to be collected, but which aren't really part of the eligibility determination?
    Normal practice is to keep the eligibilty rule 'pure', i.e. just containing the eligibility logic, and to separate out other attributes which may need to be collected, but which are not really eligibility criteria. For example:
    the Immediate Needs Assessment is complete if
    the Immediate Needs Assessment Date is known and
    the Immediate Needs Assessment Notes is known and
    it is known whether or not the person has an immediate need for assistance
    or if you just need to know the assessment date or the notes:
    the Immediate Needs Assessment is complete if
    either
    ...the Immediate Needs Assessment Date is known or
    ...the Immediate Needs Assessment Notes is known
    and
    it is known whether or not the person has an immediate need for assistance
    As long as the interview has been completed (regardless of whether or not the person is eligible), the decision report for "the Immediate Needs Assessment is complete" will show the assessment date/notes, and then the logic tree for the main eligibility rule.
    Cheers,
    Jasmine

  • How can i reuse same variables that i create using c:set var="index" /

    hi all,
    please some one helpme!!!!!!
    how can i reuse same variable that i create using
    <c:set var="index" value="${0}"/>
    cause later in the program i use index to do some condition and based on that i increment ...
    so for example if i say...
    <c:if test="${index==0}">
    <c:set var="index" value="${index+1}"/>
    </c:if>
    will it be like
    if(index==0)
    index++;
    can i do like i did be4. if not what do i need to do to reuse. cause i use the variable atleast 5 time and its keep changing on diff condition level.

    Have you tried it?
    It should work, provided you are on the same page.
    The c:set tag creates the variable in pageScope by default.
    If you forward to another JSP you need to set the scope to be "request" so that it is still available.

  • How can I add .m4r files (thatI have shortened to 30 seconds or less) to iTunes 11.0.1? I cannot find a ringtones folder in Itunes ans it won't let me drag the files to the sidebar...

    How can I add .m4r files (that I have shortened to 30 seconds or less) to iTunes 11.0.1? I cannot find a ringtones folder in Itunes and it won't let me drag the files to the sidebar...thanks!

    How can I add .m4r files (that I have shortened to 30 seconds or less) to iTunes 11.0.1? I cannot find a ringtones folder in Itunes and it won't let me drag the files to the sidebar...thanks!

  • I am using an Macbook pro in conjunction with a Time Capsule. I back up all my aperture librarys on it, but how can i view these images that are stored on the capsule please ??

    I am using an Macbook pro in conjunction with a Time Capsule. I back up all my aperture librarys on it, but how can i view these images that are stored on the capsule please ??

    If you want to see what is in a file that is backed up by time machine then you have to restore the entire file. Having said that I have had good experience with Time Machine and individual files... if the file is there then all of it's components are almost for sure there. A way to get around this in Aperture would be to use referenced images. The images then still exist as individual files and can be backed up and restored individually. You would have to do so on a file by file basis though and your album information would still only be saved within the Aperture library.

  • ICloud has loaded my contacts to my daughters iPhone how can I separate 2 devices that are on one account

    ICloud has loaded my contacts to my daughters iPhone how can I separate 2 devices that are on one account

    You can't. The whole point of iCloud is to sync contacts, calendars etc to all devices connected to the same account.
    For your daughter to maintain her own contacts and calendars in iCloud, she'll need her own iCloud account, using her own AppleID. Sign out of iCloud on your daughters phone then setup a new iCloud account for her:
    http://www.apple.com/icloud/setup/ios.html
    (Note that this does not affect purchases made from the iTunes / AppStores. You can still use different AppleIDs for both iTunes and iCloud on the same device.)

  • How can I reload previous purchases that are lost of iPod

    How can I reload itunes purchases that are lost of both my ipod and my computer?

    Use the form on this page to request a free redownload, or use the Transfer Purchases feature if applicable. If neither of these works, you will need to purchase the content again to get them back; Apple needs to pay the copyright holders for each download from the iTunes Store other than podcasts, album artwork, and iPod touch/iPhone applications.
    (38729)

  • How can you back up files that are on an external drive?

    How can you back up files that are on an external drive?

    hw999 wrote:
    How can you back up files that are on an external drive?
    Easy way, CLONE IT to another HD
    HD cloning software options:
    1. SuperDuper HD cloning software APP (free)
    2. Carbon Copy Cloner APP (will copy the recovery partition as well)
    3. Disk utility HD bootable clone.
    Methodology to protect your data. Backups vs. Archives. Long-term data protection
    https://discussions.apple.com/docs/DOC-6031
    hw999 wrote:But all I want to do is include the data that I store on an (second) external drive (internal drive getting too full) part of the auto back up process using timemachine.
    BAD IDEA
    You want one backup (ie Time machine) and one (or more) data archive of just all your raw files (drag and drop, or cloned etc.)

  • How can i put my files that are in my ipad to my computer

    how can i put my files that are in my ipad to my computer, because i deled all them from my computer, but they are in my ipad.what am i supposed to do?

    What kind of files are they and what apps are you using on the iPad with these files?

  • How can I delete duplicate songs that are appearing on my iphone but not in my itunes?

    How can I delete duplicate songs that are appearing on my iphone

    Hi jpere041,
    Thanks for visiting Apple Support Communities.
    You can delete individual songs, artists, albums, playlists, compilations and composers from your iPhone. To delete an item, swipe across it, then tap Delete.
    This information is on page 61 of the iPhone User Guide
    manuals.info.apple.com/en_US/iphone_user_guide.pdf
    Delete a song from iPhone: In Songs, swipe the song, then tap Delete.
    The song is deleted from iPhone, but not from your iTunes library on your Mac or PC, or from iCloud.
    Regards,
    Jeremy

  • How can I add a stroke to only one side of text?

    How can I add a stroke to only one side of text characters?

    I'm probably misunderstanding what you want, so I'll just ask. Is this it?

  • How can I add a song that's playing to a play list easily

    How can I add a song to a playlist whilst the song is playing?  I was sown in a store have forgotten.

    There is a short cut.  I just cant remember what it is.

  • How can I add a button that opens a new tab?

    How can I quickly open a new (blank) tab without going to File --> Open New Tab. There has to be a button I can add or a box that isn't checked somewhere. I used to be able to click in the blank space in the row of tabs to open a new tab, but with this latest Firefox update, if I click in the blank space now, it just "restores" my browser window.
    To explain further - I know I can middle-click a link to open it in a new window, but if I'm on one page reading an article, and I want to open a new tab to look up a word or map or whatever, I need a faster way to open a new blank tab.

    You are right - there should be and there is on my windows 7 machine but not on my windows 8.1 machine. Firefox add-ins are identical. So how do I get the new tab button back?

  • How can I save iPhoto Libraries that are in Trash?

    Hello. I have been having troubles with iPhoto which are basically cured at the moment. However during the process I had to drag two iPhoto Libraries to my Trash.
    My iPhoto is working fine at the moment, but I do not want to delete those two in the Trash for awhile yet. How can I get them out of Trash into a Folder to save them until I am sure I want to trash them? Can I create a Folder in Documents or Movies and save them there or some other place I can create a Folder to save them. I do not want them on my Desktop as they are quite large (15 and 22GB).
    Thanks for any ideas.

    Create a new folder on the desktop. Drag the libraries from the trash into that folder. Then put the folder where ever you want, including your Photos folder.
    The desktop and trash are just like any other folder on your Mac. Their contents are stored on your hard drive, so they are taking up the same space where ever you put them. (You have to empty trash to regain the space the contents of trash take up.)
    Larry posted the same info while I was composing
    Message was edited by: Peter Bannon

  • How Can I Seperate to Accounts that Are Currently Sharing (by accident)?

    Hi,
    I have accidentally, merged accounts with my daughter by using the same UserID (e-mail) and now they are shared.  How can i seperate the accounts again without losing any info, etc?
    Thank you

    I was thinking in line with purchased music. I have two accounts, by accident. Jobs stated on Mon day that the iCloud is the truth and iTunes Match doesn't care where you got your music. I am sorry if I gave bad advice.

Maybe you are looking for