# JavaScript and Functions

**URL:** <https://forum.kirupa.com/t/javascript-and-functions/652604>\
**Category:** programming\
**Created:** [July 12, 2022, 10:34pm UTC](https://forum.kirupa.com/t/javascript-and-functions/652604 "2022-07-12T22:34:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricVK](https://avatars.discourse-cdn.com/v4/letter/e/a5b964/32.png) [@EricVK](https://forum.kirupa.com/u/EricVK)\
**Post date:** [July 12, 2022, 10:34pm UTC](https://forum.kirupa.com/t/javascript-and-functions/652604/1 "2022-07-12T22:34:50Z")

</div>

Greetings All,  
I am somewhat new to programming, it’s been 30 years, and I have decided to dive into a bootcamp. We are learning JavaScript and I am writing an expense tracker, like a checkbook ledger.  
At the moment I am stumped. I have the ledger laid out, date, description, income/exp, and amount. I have created the first row in HTML to get things started, then the rest are created using JavaScript. Once the initial amount is entered that amount will show in a “Balance” box I created. The next entry will then add or subtract from that one, and so on.  
I am a little confused on how I go about taking the initial amount and displaying it in the “Balance” box I created. Then how to keep referring to the newly created ‘amount’ fields since they will have their own data-\* ids created for localStorage.  
I am really looking for someone to perhaps point me in the right direction because googling has done little to help me thus far so any insight you can offer will be greatly appreciated.  
Cheers,  
Eric

---

<div class="post-metadata">

**Author:** ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)\
**Post date:** [July 13, 2022, 2:16am UTC](https://forum.kirupa.com/t/javascript-and-functions/652604/2 "2022-07-13T02:16:29Z")

</div>

Hi Eric! It might be hard to help much without seeing what you are working with now. It might be a little much to try and put everything up in the forum, so maybe if you have specific questions, or we can go through things one at a time until we get everything working? What specifically are you stuck on right now?

---

<div class="post-metadata">

**Author:** ![Anushka00](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/anushka00/32/17676_2.png) [@Anushka00](https://forum.kirupa.com/u/Anushka00)\
**Post date:** [July 15, 2022, 12:01pm UTC](https://forum.kirupa.com/t/javascript-and-functions/652604/4 "2022-07-15T12:01:15Z")

</div>

Hi  
you can get hold of the amount entered through the value attribute of the form element and then set the value to the required field.  
You can use querySelectors along with getAttribute function to fill in the balance field automatically.

---

<div class="post-metadata">

**Author:** ![Wayne](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/wayne/32/16501_2.png) [@Wayne](https://forum.kirupa.com/u/Wayne)\
**Post date:** [July 16, 2022, 7:18am UTC](https://forum.kirupa.com/t/javascript-and-functions/652604/5 "2022-07-16T07:18:09Z")

</div>

You probability need a state for each part and a way to display while calculating.

If its pure javascript, you can either make a form submit or use a onChange event for each input field and display a text value after doing the calculation

If react :  
This might help [Dealing With State in React | kirupa.com](https://www.kirupa.com/react/dealing_with_state.htm)
