How to set a default value

This is difficult to explain so apologies if it is hard to understand my question.

I have form values, when I don’t bind them to cookies they sets themselves to the default value I have specified with value=

The value is used in the form calculations, but when I bind that form field to a cookie, the value is replaced by the placeholder value and it is not used by the form in the calculation. That creates some problems for me for new users.

Is there a way to insert default (initial) cookie values so if a user comes to the form for the first time the form will have default values that work in the form calculations until the user overwrites them with their own entered values (which will become their cookie values)

Hope that was understandable - I would like the value to work just as it does w/o cookies if no cookies have been saved for a user. :sos:

Just use the default format when binding the cookie value to the form input value. It should look like:

dmx-bind:value="cookies1.something.default(3)"

This way, when the cookie value is missing, the default value will be used in the input.
Just format the value using the formatter icon :slight_smile:

2 Likes

Wow, you are my super hero - I struggled with that for 10 hours yesterday and in 30 seconds you fixed my problem. Much thanks to you Teodor - I don’t know what I would do without your patient and ever present support.

It is working great but what is the formatter icon - I don’t understand that term?

When you bind a value using the data picker, there on the right side you see a magic wand icon - this triggers the formatter options. :slight_smile:

2 Likes

Ah, I always wondered what that little funnel did :smiley: Thanks again!

Really? How do you format your data then?

just in the original form statement (if that is the right word for it)

<input type="number" class="form-control" id="sugar" name="sugar" placeholder="Enter Value" value="0.0" step="0.01" data-rule-min="0" data-rule-max="100">

Sorry, I don’t understand what you mean :slight_smile:

Sorry, I had to go food shopping - I’m still learning Wappler - I know a million times more now than I did last month but you know about a trillion times more than that. I’m likely not using the right terminology so sorry I’m hard to understand. I was trying to say for the forms - the data that goes in for value= and default values is how the form data gets set - after that it only changes when a user types something into the form field on the web site.

I’'m still slowly work up the courage to try some server side processing but I wanted to get the cookies working first. With your help today I’m 85% of the distance I need to go before I move on to all the server side stuff that will really make the site meaningful for users.

I don’t get anything monetary from the site - I just have a passion for pizza making and I have been doing it for over 40 years so I want to pass along some of my knowledge before I go to the big pizza shop in the sky :smiley:

1 Like

Just so you know, I LOVE PIZZA! And what I like even more is people who have a true and honest passion for something and sacrifice a lot of their time to achieve their goals no matter what!

1 Like

Thanks Johannes, I’m 100% pizza powered :smiley:

1 Like

I am having a problem setting values for app variables and get inconsistent results. Is there some way of tracking the value of the variable for trouble shooting purposes ?

You can bind your variable value to your page and see what it returns.

{{var1.value}}

where var1 is your variable name.