# Summed fields not displaying properly

**URL:** <https://forum.wixstudio.com/t/summed-fields-not-displaying-properly/5813>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [July 28, 2018, 12:42am UTC](https://forum.wixstudio.com/t/summed-fields-not-displaying-properly/5813 "2018-07-28T00:42:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kennykung916](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/kennykung916/32/5598_2.png) [@kennykung916](https://forum.wixstudio.com/u/kennykung916)\
**Post date:** [July 28, 2018, 12:42am UTC](https://forum.wixstudio.com/t/summed-fields-not-displaying-properly/5813/1 "2018-07-28T00:42:33Z")

</div>

Trying to add two fields and then have it automatically displayed in a new textbox; used the following codes:

$w.onReady( **function** () {

**var** num1 = Number(‘#text20’)  
**var** num2 = Number(‘#text21’)

**var** numtotal = (+num1) + (+num2)

**var** text22 = numtotal

});

But text 22 does not display the sum (only gives 0 [zero]). What am I doing wrong?

Many thanks but desperately need help!

---

<div class="post-metadata">

**Author:** ![mhammouz](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/mhammouz/32/4033_2.png) [@mhammouz](https://forum.wixstudio.com/u/mhammouz)\
**Post date:** [July 29, 2018, 12:40pm UTC](https://forum.wixstudio.com/t/summed-fields-not-displaying-properly/5813/2 "2018-07-29T12:40:26Z")

</div>

Hi Kenny,

First problem is the declaration of your text box, you should take the value of that text box also round it with Number, so it should look something like that :

```javascript
Number($w("#text20").value);

```

second, your textbox 22 looks like a variable, it should be an element so that you can show the results.  
Also, to be aware of, you put your code in the onReady function without any button, so it will only work once ( when the page ready )

Here is a snippet code to make it easier to see how it works:

- Note : we have 2 text boxes and a Text that shows the result.

```javascript
let x = Number($w("#text20").value) + Number($w('#text21').value);

    $w("#total").text = x.toString();

```

Hope this helps!  
Best.

Mustafa
