Getting value from custom input instead of buttons

So, this is the last little thing I have left for this project. Right now, the application returns the correct tip and bill per person. I have a input where a user can enter a custom tip, and I can not get the value the same way I get the value from the tip buttons. I get the tip button value from click event, but the custom input has to be clicked on to enter the custom tip. So, that initial click does not hold a value for the custom tip. Not sure what would be the best way to get that custom tip value.

What’s your question specifically?

Hey there… Took a quick look at your tip situation:

here’s what I found I believe line 52:

const customTip = () => {
  const custom = document.querySelector

It seems to me you are not “selecting” anything.
Hope that helps

Appreciate it but I knew that was there. That was the function I started writing, but realized I had a issue on what I was going to make the function do.

You can see the I get the button tip values from a click, but I can not use that on a input. I made the function get the value using blur, but now I am stuck on how I can include that value in my calculation function to get the correct bill and tip if the user enter a custom tip

Ah I think i understand.

For the tip buttons you’re listening for a click event, but when you’re typing in a value you’re not clicking.
So you need to find which event you want apply an event listener to when the input value changes

You’re close so I don’t want to tell you the answer exactly, but see if you can find it by Googling what your looking for with the MDN docs

Once you’re past that, I also got confused with the custom tip value. I put in 2% and it thought I meant 2x instead, so my $100 bill came with a $200 tip! So you’ll have to convert it to percentages so it’s aligned with the tip buttons

Right, so I tested and I get the value from the input when I use blur for the add event. Change might be a better option. Right now, I just need to work out the logic to check to see if a button is pressed. If the tip button is pressed then I need to use that logic to find the correct bill and tip per person. If the button was not clicked, but the input has a value then I need to use logic to use that value for the correct tip and bill per person

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.