# Addition of numbers not displaying on page

**URL:** <https://forum.wixstudio.com/t/addition-of-numbers-not-displaying-on-page/27485>\
**Category:** Ask the community\
**Tags:** code, question\
**Created:** [November 11, 2020, 3:16am UTC](https://forum.wixstudio.com/t/addition-of-numbers-not-displaying-on-page/27485 "2020-11-11T03:16:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dean41146](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dean41146/32/16097_2.png) [@dean41146](https://forum.wixstudio.com/u/dean41146)\
**Post date:** [November 11, 2020, 3:16am UTC](https://forum.wixstudio.com/t/addition-of-numbers-not-displaying-on-page/27485/1 "2020-11-11T03:16:36Z")

</div>

I have 3 text input elements. Two of the input fields are populated with numbers from a dropdown change event. In the third input I want to have the sum of the other two fields. The problem is that the result of the addition does not display in the 3rd field.

Here is my code:

```javascript
export function update_click(event) {
    value = Number($w("#depositAmt").value);
    value1 = Number($w("#firstMonthAmt").value);
    value2 = Number($w("#depositTotal").value);

    value2 = value + value1;
    console.log(typeof value2, value2);
    console.log(typeof value, value);
    console.log(typeof value1, value1);
}

```

The output in the console is what I want in ‘depositTotal’ but cannot get it like that on the page.  
This is what is logged in the console:

 ![](https://us1.discourse-cdn.com/wix/original/3X/b/9/b97e76984c9b2dcf7870361ad0d243b085599a71.png)  
Any advice appreciated.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 11, 2020, 6:59am UTC](https://forum.wixstudio.com/t/addition-of-numbers-not-displaying-on-page/27485/2 "2020-11-11T06:59:31Z")

</div>

Your code isn’t setting the **depositTotal** field. You will want to do something like this:

```javascript
$w("#depositTotal").value = '' + value2;

```

Note: a null string ‘’ is added to value2 to force it to be a string instead of a number.

---

<div class="post-metadata">

**Author:** ![dean41146](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dean41146/32/16097_2.png) [@dean41146](https://forum.wixstudio.com/u/dean41146)\
**Post date:** [November 11, 2020, 7:17am UTC](https://forum.wixstudio.com/t/addition-of-numbers-not-displaying-on-page/27485/3 "2020-11-11T07:17:14Z")

</div>

I’ve changed my code:

```javascript
export function update_click(event) {
    value = $w("#depositAmt").value;
    value1 = $w("#firstMonthAmt").value;
    value2 = value + value1;

    $w("#depositTotal").value = '' + value2;

    console.log(typeof value2, value2);
    console.log(typeof value, value);
    console.log(typeof value1, value1);
}

```

In the console I have:

![](https://us1.discourse-cdn.com/wix/original/3X/3/4/34b14227bac124b1fdc986958b024c92e047297e.png)

I still have nothing on the actual page.

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 11, 2020, 7:32am UTC](https://forum.wixstudio.com/t/addition-of-numbers-not-displaying-on-page/27485/4 "2020-11-11T07:32:22Z")

</div>

Is depositTotal a text input field, or a plain text field?

You still need to convert the fields to numbers in order to perform the addition:

```javascript
let value = Number($w("#depositAmt").value);
let value1 = Number($w("#firstMonthAmt").value);
let value2 = value + value1;

// the next line depends on what type of text element you're using
$w("#depositTotal").value = value2; // for input field
$w("#depositTotal").text = value2; // for text field

```

---

<div class="post-metadata">

**Author:** ![yisrael-wix](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/yisrael-wix/32/1107_2.png) [@yisrael-wix](https://forum.wixstudio.com/u/yisrael-wix)\
**Post date:** [November 11, 2020, 8:51am UTC](https://forum.wixstudio.com/t/addition-of-numbers-not-displaying-on-page/27485/5 "2020-11-11T08:51:45Z")

</div>

Also, as stated in the [Forum Policies and Guidelines](https://www.wix.com/corvid/forum/community-discussion/forum-policies-and-guidelines) , do not post in ALL CAPS. That means both the Title and the post itself.

---

<div class="post-metadata">

**Author:** ![dean41146](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dean41146/32/16097_2.png) [@dean41146](https://forum.wixstudio.com/u/dean41146)\
**Post date:** [November 11, 2020, 9:45am UTC](https://forum.wixstudio.com/t/addition-of-numbers-not-displaying-on-page/27485/6 "2020-11-11T09:45:02Z")

</div>

Thank you very much for your help. That solved the problem.

---

<div class="post-metadata">

**Author:** ![dean41146](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/dean41146/32/16097_2.png) [@dean41146](https://forum.wixstudio.com/u/dean41146)\
**Post date:** [November 11, 2020, 9:45am UTC](https://forum.wixstudio.com/t/addition-of-numbers-not-displaying-on-page/27485/7 "2020-11-11T09:45:38Z")

</div>

Ok, apologies. I have corrected.
