Turning text box into currency

Having a headache trying to format a text box to be $ currency. I can only get to the currenct converter after turning a text box into a number using the expression fields but that doesn’t work. Please guide me as to how to do this. I know it’s got to be pretty simple so racking my brain that I can’t figure it out.

Thanks,
Rick

What do you mean? What are you trying to format exactly - a value of a field, a field itself? Is there an example of what you are trying to achieve?

sure have a look, its just a proposal form for quoting jobs to customers. Most of the boxes are currency. At the moment, it is just a local form. I do intend to store all of this in a database but wanted to figure out what I wanted first.

https://www.marsalstudios.com/admin/proposal-sheet.php

So which part of this page needs formatting and what do you need to do exactly?

the subtotal, sales tax and total boxes at the bottom right end should be formatted as currency. Those are the most important ones. However, there are many more boxes which add up to these which get displayed when you hit the buttons.

I had to convert text boxes to numbers in order to calculate totals which is fine although I would have thought that by specifying the box as a number it would have been ok. The calculations don’t work otherwise. Now I just need to make it look nice by putting in $ sign and 2 decimal places.

As far as what I’m trying to do is just make it fast to create a quote on the fly in front of a customer without having to calculate by hand. My wife currently does this by hand and it takes her a few minutes which seems like a long time when you have a customer waiting. I wanted a form which she could just touch buttons and add quantities to create it. I have it working and is really fast to create, now I just have to make it something worth showing a customer and printing out. Eventually, I’d like to have the customer sign electronically as a contract. All doable in time.

Hope this helps give you background. The formating is what I need help with right now.

Rick

not sure if you meant to send a reply, didn’t get anything but the system said i had a post from Ben.

any advice on formating form data in a textbox to display as currency

here is the dilemma:

input id=“text320” name=“text320” type=“number” class=“form-control” dmx-bind:value=“text300.value.toNumber() + (text310.value.toNumber())”

the above works to calculate two textinput boxes and results in a plain number. However the following doesn’t:

input id=“text320” name=“text320” type=“number” class=“form-control” dmx-bind:value=“text300.value.toNumber().formatCurrency(”$", “.”, “,”, “2”) + (text310.value.toNumber().formatCurrency("$", “.”, “,”, “2”))"

So you want to format the content of the text inputs?

This won't work like this. You need to apply the currency formatting after the calculations, like:

dmx-bind:value="(text300.value.toNumber() + text310.value.toNumber()).formatCurrency("$", ".", ",", "2")"

However i do have a question here - why are you using form inputs for total, tax and subtotal? Why not just showing the values there as text bindings?

that makes sense, but it still doesn’t work exactly as you sent it.
The reason I’m using text boxes is that the data needs to be editable before saving to the database as happens during a negotiation.

I’ve tried a lot of combinations for the parentheses and single vs double quotes vs &quot . It does work when there aren’t calculations. ???

i can confirm this does not work. have a similar use case where calculating 2 values from text box and have to show the value with currency and 2 decimal places.

however, this did work for us @marsalstudios, give this a shot:

dmx-text="'Repayment: '.concat(((sliderLoanAmt.value.toNumber() * 2) / (sliderLoanDuration.value.toNumber() * 7)).toFixed(0).toNumber().formatCurrency("$ ", ".", ",", 0)).concat(' per week')"

had to type it manually though! is not possible visually through Wappler.

@Teodor please see if this is good enough to be included as a feature in future?

thanks @nshkrsh . Wow, calculating then converting to string (toFixed) then number, then currency works? I’ll try it. I agree manually coding the formulas makes sense in these cases. The logic is hard make happen in the visual builder. That’s probably why it doesn’t work right at this stage. Can’t knock Wappler though, it’s so much more flexible than other data tools. It will only get better.

Rick

love Wappler. nothing like it.

not at all ranting in negative tone. just nudging to make it better. which they are, week by week. which is incredible.

the ability to maneuver things manually if a visual way is not available is indeed a great feature in it’s own, not a limitation!

yes, absolutely agree.