**let** punkte = $w ( '#PunkteKonto' ). getCurrentItem (). punkte ;
**if** ( **typeof** punkte === 'string' ) {
punkte = Number ( punkte );
**if** ( punkte < nextlevelpunkte ) {
$w ( '#progressBar1' ). value = punkte ;
}}}})
The if condition is not so clear (the logics there is not correct. Why does the typeof punkte depend on the type of nextlevelpuncte? Aren’t they independent fields?).
Anyway, why wouldn’t store all the puncte & next level as numbers?
To show the textual value, put a text element over the progress bar and use:
Yes you are right, they are independent fields.
Next Level: is for the target value of the progressbar &
Punkte: is for the value in the progress bar
Reason for not storing the fields as numbers is that I got the values
from googlesheets and can not set them up in googlesheets in the
needed format for Wix.
Or do you have an idea how to set it up from googlesheets?
Green is the manual change in Wix. As I get a lot of numbers, manual change is not sufficient.
Red is the format from googlesheets. Thats why I want to use code.
You can make it a number even where you import it from google spreadsheet. Explain to me how you imported it from google spreadsheet and I’ll tell you how to convert it into number.
Anyway, if you wish to keep it a string, you can do:
const item = $w('#PunkteKonto').getCurrentItem();
$w('#progressBar').value = Number(item.punkte.trim());
$w('#progressBar').targetValue= Number(item.nextLevel.trim());
$w('#progressBarText').text = Number(item.punkte.trim()).toLocaleString();
//if you don't want to format it as locale (i.e. locale String is with comma/point after the thousands depends on the visitor's country convention) you can just do: $w('#progressBarText').text = item.punkte;
//P.S. the trim method used to get rid of unwanted spaces before and after the number string.